Cache the value returned by the property #4429
Unanswered
joseangelmt
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm embedding Python in an application. The principal mission of the implementation is to expose to the Python world already instantiated C++ objects via py::cast(), so my py::class_<..> classes don't have any constructor. Python users can't instantiate these objects.
One of the exposed C++ objects has a std::map<> field with data non compatible with Python. This field is exposed to Python via def_property_readonly(...) that implements a lambda that constructs and returns a py::dict.
Creating this py::dict can be a bottleneck so I wish to cache it in memory, so it's created only the first time.
Is it possible to do it?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions