diff options
Diffstat (limited to 'docs/serialization.rst')
-rw-r--r-- | docs/serialization.rst | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/docs/serialization.rst b/docs/serialization.rst index 3e4cf9e..fe09f9d 100644 --- a/docs/serialization.rst +++ b/docs/serialization.rst @@ -51,9 +51,24 @@ UnitRegistry dependent. In certain cases, you want a binary representation of the data. Python's standard algorithm for serialization is called Pickle_. Pint quantities implement the magic `__reduce__` method and therefore can be *Pickled* and *Unpickled*. However, you have to bear in mind, that -the **DEFAULT_REGISTRY** is used for unpickling and this might be different from the one -that was used during pickling. If you want to have control over the deserialization, the -best way is to create a tuple with the magnitude and the units: +the **application registry** is used for unpickling and this might be different from the one +that was used during pickling. + +By default, the application registry is one initialized with :file:`defaults_en.txt`; in +other words, the same as what you get when creating a :class:`pint.UnitRegistry` without +arguments and without adding any definitions afterwards. + +If your application is fine just using :file:`defaults_en.txt`, you don't need to worry +further. + +If your application needs a single, global registry with custom definitions, you must +make sure that it is registered using :func:`pint.set_application_registry` before +unpickling anything. You may use :func:`pint.get_application_registry` to get the +current instance of the application registry. + +Finally, if you need multiple custom registries, it's impossible to correctly unpickle +:class:`pint.Quantity` or :class:`pint.Unit` objects.The best way is to create a tuple +with the magnitude and the units: .. doctest:: |