Pickle pya.X objects

Hello,

I need to pickle pya objects but dump command returns an error.

Here is the short example

import pya
import pickle
file = open('lt.pkl', 'wb')
pickle.dump(pya.Layout(), file)
file.close()

Error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[22], line 2
      1 file = open('lt.pkl', 'wb')
----> 2 pickle.dump(pya.Layout(), file)
      3 file.close()

TypeError: cannot pickle 'Layout' object

Is there way to use Pickle?

thank you,
Alex

Comments

  • No, there is not.

    These classes are wrappers to C++ objects and not Python-alike objects. There is no "structure" pickle could use for serialization. The API design is not driven by an object aggregation idea. Instead the objects are peek holes into a highly optimized data base. That is contrary to the idea of a bidirectional get/set API that pickle uses for serialization.

    And specifically Layout objects can be super heavy (we're literally talking about billions of "objects") - you do no really want to serialize these objects through an Python API.

    Matthias

Sign In or Register to comment.