@@ -212,65 +212,49 @@ def unpackb(object packed, *, object object_hook=None, object list_hook=None,
212
212
213
213
214
214
cdef class Unpacker(object ):
215
- """ Streaming unpacker.
216
-
217
- Arguments:
218
-
219
- :param file_like:
220
- File-like object having `.read(n)` method.
221
- If specified, unpacker reads serialized data from it and :meth:`feed()` is not usable.
222
-
223
- :param int read_size:
224
- Used as `file_like.read(read_size)`. (default: `min(1024**2, max_buffer_size)`)
225
-
226
- :param bool use_list:
227
- If true, unpack msgpack array to Python list.
228
- Otherwise, unpack to Python tuple. (default: True)
229
-
230
- :param bool raw:
231
- If true, unpack msgpack raw to Python bytes.
232
- Otherwise, unpack to Python str by decoding with UTF-8 encoding (default).
215
+ """
216
+ MessagePack Packer
233
217
234
- :param bool strict_map_key:
235
- If true (default), only str or bytes are accepted for map (dict) keys.
218
+ Usage::
236
219
237
- :param callable object_hook:
238
- When specified, it should be callable.
239
- Unpacker calls it with a dict argument after unpacking msgpack map.
240
- (See also simplejson)
220
+ packer = Packer()
221
+ astream.write(packer.pack(a))
222
+ astream.write(packer.pack(b))
241
223
242
- :param callable object_pairs_hook:
243
- When specified, it should be callable.
244
- Unpacker calls it with a list of key-value pairs after unpacking msgpack map.
245
- (See also simplejson)
224
+ Packer's constructor has some keyword arguments:
246
225
247
- :param int max_buffer_size:
248
- Limits size of data waiting unpacked. 0 means system's INT_MAX.
249
- The default value is 100*1024*1024 (100MiB).
250
- Raises `BufferFull` exception when it is insufficient.
251
- You should set this parameter when unpacking data from untrusted source.
226
+ :param callable default:
227
+ Convert user type to builtin type that Packer supports.
228
+ See also simplejson's document.
252
229
253
- :param int max_str_len:
254
- Deprecated, use *max_buffer_size* instead.
255
- Limits max length of str. (default: max_buffer_size)
230
+ :param bool use_single_float:
231
+ Use single precision float type for float. (default: False)
256
232
257
- :param int max_bin_len :
258
- Deprecated, use *max_buffer_size* instead .
259
- Limits max length of bin. (default: max_buffer_size)
233
+ :param bool autoreset :
234
+ Reset buffer after each pack and return its content as `bytes`. (default: True) .
235
+ If set this to false, use `bytes()` to get content and `.reset()` to clear buffer.
260
236
261
- :param int max_array_len:
262
- Limits max length of array. (default: max_buffer_size)
237
+ :param bool use_bin_type:
238
+ Use bin type introduced in msgpack spec 2.0 for bytes.
239
+ It also enables str8 type for unicode. (default: True)
263
240
264
- :param int max_map_len:
265
- Limits max length of map. (default: max_buffer_size//2)
241
+ :param bool strict_types:
242
+ If set to true, types will be checked to be exact. Derived classes
243
+ from serializable types will not be serialized and will be
244
+ treated as unsupported type and forwarded to default.
245
+ Additionally tuples will not be serialized as lists.
246
+ This is useful when trying to implement accurate serialization
247
+ for python types.
266
248
267
- :param int max_ext_len:
268
- Deprecated, use *max_buffer_size* instead.
269
- Limits max size of ext type. (default: max_buffer_size)
249
+ :param bool datetime:
250
+ If set to true, datetime with tzinfo is packed into Timestamp type.
251
+ Note that the tzinfo is stripped in the timestamp.
252
+ You can get UTC datetime with `timestamp=3` option of the Unpacker.
253
+ (Python 2 is not supported).
270
254
271
255
:param str unicode_errors:
272
- Error handler used for decoding str type. (default: ` 'strict'` )
273
-
256
+ The error handler for encoding unicode. (default: 'strict')
257
+ DO NOT USE THIS!! This option is kept for very specific usage.
274
258
275
259
Example of streaming deserialize from file-like object::
276
260
0 commit comments