You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{meth}`register_structure_hook_factory() <cattrs.BaseConverter.register_structure_hook_factory>` can also be used as decorators.
125
127
126
-
When registered via decorators, hook factories can receive the current converter by exposing an additional required parameter.
127
-
128
128
Here's an example of using an unstructure hook factory to handle unstructuring [queues](https://docs.python.org/3/library/queue.html#queue.Queue).
129
129
130
130
```{doctest}
@@ -158,7 +158,9 @@ Here's an example of using an unstructure hook factory to handle unstructuring [
158
158
## Using `cattrs.gen` Generators
159
159
160
160
The {mod}`cattrs.gen` module allows for generating and compiling specialized hooks for unstructuring _attrs_ classes, dataclasses and typed dicts.
161
-
The default {class}`Converter <cattrs.Converter>`, upon first encountering one of these types, will use the generation functions mentioned here to generate specialized hooks for it, register the hooks and use them.
161
+
The default {class}`Converter <cattrs.Converter>`, upon first encountering one of these types,
162
+
will use the generation functions mentioned here to generate specialized hooks for it,
163
+
register the hooks and use them.
162
164
163
165
One reason for generating these hooks in advance is that they can bypass a lot of _cattrs_ machinery and be significantly faster than normal _cattrs_.
164
166
The hooks are also good building blocks for more complex customizations.
0 commit comments