FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
msgpack-python/msgpack/__init__.py at main · zdccool/msgpack-python · GitHub
zdccool
/
msgpack-python
Public
forked from
msgpack/msgpack-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
msgpack-python
/
msgpack
/
__init__.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
54 lines (39 loc) · 1.09 KB
Breadcrumbs
msgpack-python
/
msgpack
/
__init__.py
Copy path
File metadata and controls
54 lines (39 loc) · 1.09 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# coding: utf-8
from
.
_version
import
version
from
.
exceptions
import
*
from
.
ext
import
ExtType
,
Timestamp
import
os
import
sys
if
os
.
environ
.
get
(
"MSGPACK_PUREPYTHON"
)
or
sys
.
version_info
[
0
]
==
2
:
from
.
fallback
import
Packer
,
unpackb
,
Unpacker
else
:
try
:
from
.
_cmsgpack
import
Packer
,
unpackb
,
Unpacker
except
ImportError
:
from
.
fallback
import
Packer
,
unpackb
,
Unpacker
def
pack
(
o
,
stream
,
**
kwargs
):
"""
Pack object `o` and write it to `stream`
See :class:`Packer` for options.
"""
packer
=
Packer
(
**
kwargs
)
stream
.
write
(
packer
.
pack
(
o
))
def
packb
(
o
,
**
kwargs
):
"""
Pack object `o` and return packed bytes
See :class:`Packer` for options.
"""
return
Packer
(
**
kwargs
).
pack
(
o
)
def
unpack
(
stream
,
**
kwargs
):
"""
Unpack an object from `stream`.
Raises `ExtraData` when `stream` contains extra bytes.
See :class:`Unpacker` for options.
"""
data
=
stream
.
read
()
return
unpackb
(
data
,
**
kwargs
)
# alias for compatibility to simplejson/marshal/pickle.
load
=
unpack
loads
=
unpackb
dump
=
pack
dumps
=
packb
Back
|
FazBrowse Home
|
New Git URL