Closed root-11 closed 1 year ago
I believe this is a part of the game: pybind11 keeping objects alive but I am clueless whether nimpy
support this.
Most ref objects will do what you want. Just return your ref object from a nim function, then pass it to other nim functions.
Also you can try exporting nim classes
How to keep long-lived objects alive from python?
Most examples I've seen use
nimpy
in a functional capacity such as in this example, but is it possible to use nimpy - just like sqlite - where a C object is instantiated once and kept alive for interaction in further subsequent calls?In the example below
db
is an in-memory object that is kept alive for subsequent transactions:In numpy the same wrapping occurs:
I would be grateful for a brief example on how this may be done?
Something as simple as this would do:
Kind regards root-11