Hello, My question is: which parts of a code I should modify to add internal property maps of custom type? Is it possible without ground-breaking modifications, or should I look a way for some workaround?
My usecase is to bridge python integer objects and big integer objects (from intx library) on c++ side, as a vertex property. I'm going to perform relatively heavy math operations and graph operations, so I want to write a C++ extension that does it. So I thought, is it possible to add custom property map handlers for big integers, that will convert python long objects to intx type and store it in that type later.
Am 13.07.21 um 21:58 schrieb sebyakin.a:
Hello, My question is: which parts of a code I should modify to add internal property maps of custom type? Is it possible without ground-breaking modifications, or should I look a way for some workaround?
My usecase is to bridge python integer objects and big integer objects (from intx library) on c++ side, as a vertex property. I'm going to perform relatively heavy math operations and graph operations, so I want to write a C++ extension that does it. So I thought, is it possible to add custom property map handlers for big integers, that will convert python long objects to intx type and store it in that type later.
The simplest thing for you to do is to use Boost.Python to reflect your custom types to python, which then you can store in a property map of type "python::object". You can access the property map values from your C++ extension by using python::extract().
Thank you for the reply! Do you know, is there's any noticeable overhead of frequent python::extract() calls? Is it urgent to have some pre-extracted data-structure on c++ side, or this is similar to having a pointer?
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
вторник, 13 июля 2021 г., 23:44, Tiago de Paula Peixoto tiago@skewed.de написал(а):
Am 13.07.21 um 21:58 schrieb sebyakin.a:
Hello,
My question is: which parts of a code I should modify to add internal
property maps of custom type? Is it possible without ground-breaking
modifications, or should I look a way for some workaround?
My usecase is to bridge python integer objects and big integer objects
(from intx library) on c++ side, as a vertex property. I'm going to
perform relatively heavy math operations and graph operations, so I want
to write a C++ extension that does it.
So I thought, is it possible to add custom property map handlers for big
integers, that will convert python long objects to intx type and store
it in that type later.
The simplest thing for you to do is to use Boost.Python to reflect your
custom types to python, which then you can store in a property map of
type "python::object". You can access the property map values from your
C++ extension by using python::extract().
Tiago de Paula Peixoto tiago@skewed.de
graph-tool mailing list -- graph-tool@skewed.de
To unsubscribe send an email to graph-tool-leave@skewed.de
Am 14.07.21 um 09:46 schrieb sebyakin.a:
Thank you for the reply! Do you know, is there's any noticeable overhead of frequent python::extract() calls? Is it urgent to have some pre-extracted data-structure on c++ side, or this is similar to having a pointer?
It will incur an overhead, since the python interpreter needs to be involved. So it's better to do this once, ahead of time, and preferably store all property map values in a single python object.
One more question: if I want these c++ objects, that are exposed to python with boost::python, to be an internal property maps and so be (de)serialized with the graph (from)into .gt format, should I write a boost::python pickle support functions for these classes? Will it work?
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
вторник, 13 июля 2021 г., 23:44, Tiago de Paula Peixoto tiago@skewed.de написал(а):
Am 13.07.21 um 21:58 schrieb sebyakin.a:
Hello,
My question is: which parts of a code I should modify to add internal
property maps of custom type? Is it possible without ground-breaking
modifications, or should I look a way for some workaround?
My usecase is to bridge python integer objects and big integer objects
(from intx library) on c++ side, as a vertex property. I'm going to
perform relatively heavy math operations and graph operations, so I want
to write a C++ extension that does it.
So I thought, is it possible to add custom property map handlers for big
integers, that will convert python long objects to intx type and store
it in that type later.
The simplest thing for you to do is to use Boost.Python to reflect your
custom types to python, which then you can store in a property map of
type "python::object". You can access the property map values from your
C++ extension by using python::extract().
Tiago de Paula Peixoto tiago@skewed.de
graph-tool mailing list -- graph-tool@skewed.de
To unsubscribe send an email to graph-tool-leave@skewed.de
Am 03.08.21 um 13:32 schrieb sebyakin.a:
One more question: if I want these c++ objects, that are exposed to python with boost::python, to be an internal property maps and so be (de)serialized with the graph (from)into .gt format, should I write a boost::python pickle support functions for these classes? Will it work?
Yes, pickling is supported for property maps of type boost::python, provided the values themselves can be pickled.