Skip to content

Commit

Permalink
Clarify field order in array_like=True structs
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist committed Jul 7, 2022
1 parent fa9dbb4 commit f092b90
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,10 @@ doesn't match or if any required fields are missing.
msgspec.DecodeError: Expected `str`, got `int` - at `$.groups[1]`
If you pass ``array_like=True`` when defining the struct type, they're instead
treated as ``array`` types during encoding/decoding (with fields serialized in
their definition order). This can further improve performance at the cost of
less human readable messaging. Like ``array_like=False`` (the default) structs,
treated as ``array`` types during encoding/decoding. In this case fields are
serialized in their normalized order (definition order, with optional fields
shifted to the end). This can further improve performance at the cost of less
human readable messaging. Like ``array_like=False`` (the default) structs,
extra (trailing) fields are ignored during decoding, and any missing optional
fields have their defaults applied. Type checking also still applies.

Expand Down Expand Up @@ -643,7 +644,7 @@ message).
>>> # Compose a larger message containing the pre-encoded fragment
... msg = {"a": 1, "b": fragment}
>>> # During encoding, the raw message is efficiently copied into
>>> # During encoding, the raw message is efficiently copied into
... # the output buffer, avoiding any extra encoding cost
... msgspec.json.encode(msg)
b'{"a":1,"b":{"x": 1, "y": 2}}'
Expand Down

0 comments on commit f092b90

Please sign in to comment.