@@ -8112,11 +8112,14 @@ PyDoc_STRVAR(struct_asdict__doc__,
81128112"Convert a struct to a dict.\n"
81138113"\n"
81148114"This is a one-to-one conversion of the struct instance, modeled after\n"
8115- "``dataclasses.asdict``. Every field is included unchanged - the\n"
8116- "``omit_defaults`` struct option is ignored, ``UNSET`` values are kept,\n"
8117- "and nested ``Struct`` fields are *not* recursively converted. Use\n"
8118- "``msgspec.to_builtins`` instead when the output is intended for\n"
8119- "serialization.\n"
8115+ "``dataclasses.asdict``. Every field is included unchanged using its raw\n"
8116+ "attribute name. Struct-level settings (``rename``, ``tag``,\n"
8117+ "``omit_defaults``, ``array_like``) are ignored, ``UNSET`` values are\n"
8118+ "kept, nested ``Struct`` / ``dataclass`` / ``attrs`` fields are not\n"
8119+ "recursively converted, and no value-level conversions are applied (e.g.\n"
8120+ "``bytes`` is not base64-encoded, ``datetime`` is not converted to a\n"
8121+ "string). Use ``msgspec.to_builtins`` instead when the output is intended\n"
8122+ "for serialization.\n"
81208123"\n"
81218124"Parameters\n"
81228125"----------\n"
@@ -8177,11 +8180,13 @@ PyDoc_STRVAR(struct_astuple__doc__,
81778180"Convert a struct to a tuple.\n"
81788181"\n"
81798182"This is a one-to-one conversion of the struct instance, modeled after\n"
8180- "``dataclasses.astuple``. Every field is included unchanged - the\n"
8181- "``omit_defaults`` struct option is ignored, ``UNSET`` values are kept,\n"
8182- "and nested ``Struct`` fields are *not* recursively converted. Use\n"
8183- "``msgspec.to_builtins`` instead when the output is intended for\n"
8184- "serialization.\n"
8183+ "``dataclasses.astuple``. Every field value is included unchanged.\n"
8184+ "Struct-level settings (``omit_defaults``, ``array_like``, ``tag``) are\n"
8185+ "ignored, ``UNSET`` values are kept, nested ``Struct`` / ``dataclass`` /\n"
8186+ "``attrs`` fields are not recursively converted, and no value-level\n"
8187+ "conversions are applied (e.g. ``bytes`` is not base64-encoded,\n"
8188+ "``datetime`` is not converted to a string). Use ``msgspec.to_builtins``\n"
8189+ "instead when the output is intended for serialization.\n"
81858190"\n"
81868191"Parameters\n"
81878192"----------\n"
@@ -20438,14 +20443,23 @@ PyDoc_STRVAR(msgspec_to_builtins__doc__,
2043820443"commonly supported by Python serialization libraries.\n"
2043920444"\n"
2044020445"This is mainly useful for adding msgspec support for other protocols, or\n"
20441- "for cases where msgspec is only processing part of a message. Encoder\n"
20442- "settings are applied during conversion: ``omit_defaults`` on ``Struct``\n"
20443- "types is honored, and fields containing ``msgspec.UNSET`` are omitted\n"
20444- "from the output. Nested ``Struct`` / ``dataclass`` / ``attrs`` / ``TypedDict``\n"
20445- "/ ``NamedTuple`` values are recursively converted.\n"
20446+ "for cases where msgspec is only processing part of a message. The\n"
20447+ "conversion applies the same semantics as the ``json``/``msgpack``\n"
20448+ "encoders:\n"
2044620449"\n"
20447- "``msgspec.structs.asdict`` and ``msgspec.structs.astuple`` perform a\n"
20448- "one-to-one conversion and ignore these settings.\n"
20450+ "- Struct-level settings are honored: ``rename``, ``omit_defaults``,\n"
20451+ " ``tag`` for tagged unions, and ``array_like``.\n"
20452+ "- Fields containing ``msgspec.UNSET`` are omitted from the output.\n"
20453+ "- Nested ``Struct`` / ``dataclass`` / ``attrs`` / ``TypedDict`` /\n"
20454+ " ``NamedTuple`` values are recursively converted.\n"
20455+ "- Types that don't map directly to builtins are converted: ``bytes`` /\n"
20456+ " ``bytearray`` / ``memoryview`` to base64 string, ``datetime`` /\n"
20457+ " ``date`` / ``time`` / ``timedelta`` to ISO 8601 string, ``uuid.UUID``\n"
20458+ " and ``decimal.Decimal`` to string, ``set`` / ``frozenset`` to list,\n"
20459+ " ``Enum`` to its member value.\n"
20460+ "\n"
20461+ "``msgspec.structs.asdict`` and ``msgspec.structs.astuple`` do none of\n"
20462+ "this: they perform a one-to-one conversion of a single struct instance.\n"
2044920463"\n"
2045020464"Parameters\n"
2045120465"----------\n"
0 commit comments