Skip to content

Step 1 of 5 · Reading · ~1 min

Read

Implementation

Encoder Implementation

Encoder picks smallest format:

python

Performance:

  • Build via list of bytes objects + b''.join.
  • Avoids quadratic concat.
  • Modern Python: BytesIO also fine.

Roundtrip:

python

Custom types:

  • Pre-encode hook: user provides function for non-built-in types.
  • Most libs return ExtType for user-registered types.

Streaming encode:

  • For huge maps/arrays: emit length, then stream items.
  • Saves memory.
Up nextMessagePack vs JSON vs OthersProduction

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…