MCPcopy Create free account
hub / github.com/ccxt/ccxt / Packer

Class Packer

python/ccxt/static_dependencies/msgpack/fallback.py:607–951  ·  view source on GitHub ↗

MessagePack Packer Usage:: packer = Packer() astream.write(packer.pack(a)) astream.write(packer.pack(b)) Packer's constructor has some keyword arguments: :param default: When specified, it should be callable. Convert user type to builtin t

Source from the content-addressed store, hash-verified

605
606
607class Packer:
608 """
609 MessagePack Packer
610
611 Usage::
612
613 packer = Packer()
614 astream.write(packer.pack(a))
615 astream.write(packer.pack(b))
616
617 Packer's constructor has some keyword arguments:
618
619 :param default:
620 When specified, it should be callable.
621 Convert user type to builtin type that Packer supports.
622 See also simplejson's document.
623
624 :param bool use_single_float:
625 Use single precision float type for float. (default: False)
626
627 :param bool autoreset:
628 Reset buffer after each pack and return its content as `bytes`. (default: True).
629 If set this to false, use `bytes()` to get content and `.reset()` to clear buffer.
630
631 :param bool use_bin_type:
632 Use bin type introduced in msgpack spec 2.0 for bytes.
633 It also enables str8 type for unicode. (default: True)
634
635 :param bool strict_types:
636 If set to true, types will be checked to be exact. Derived classes
637 from serializable types will not be serialized and will be
638 treated as unsupported type and forwarded to default.
639 Additionally tuples will not be serialized as lists.
640 This is useful when trying to implement accurate serialization
641 for python types.
642
643 :param bool datetime:
644 If set to true, datetime with tzinfo is packed into Timestamp type.
645 Note that the tzinfo is stripped in the timestamp.
646 You can get UTC datetime with `timestamp=3` option of the Unpacker.
647
648 :param str unicode_errors:
649 The error handler for encoding unicode. (default: 'strict')
650 DO NOT USE THIS!! This option is kept for very specific usage.
651
652 Example of streaming deserialize from file-like object::
653
654 unpacker = Unpacker(file_like)
655 for o in unpacker:
656 process(o)
657
658 Example of streaming deserialize from socket::
659
660 unpacker = Unpacker()
661 while True:
662 buf = sock.recv(1024**2)
663 if not buf:
664 break

Callers 2

packFunction · 0.85
packbFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…