openPMD / openPMD-api

:floppy_disk: C++ & Python API for Scientific I/O
https://openpmd-api.readthedocs.io
GNU Lesser General Public License v3.0
134 stars 51 forks source link

Fix Python container and pickle API #1627

Closed franzpoeschel closed 2 weeks ago

franzpoeschel commented 3 weeks ago

Follow-up to #1154.

In the Python API, it was so far impossible to actually get a handle to a scalar record component due to the reference return type of __getitem__. Python was smart enough to find out the actual type of the reference: the scalar record component IS its containing Record. This can lead to problems such as infinite recursion when traversing over the object model in our Python API.

This additionally meant that no one ever noticed that I forgot handling scalar record components in #1154 for Python pickling, since those objects were impossible to obtain in Python. This adds the missing logic.