In order to speed up my code, I am using Cython. I was wondering whether it is possible to fix the type of attributes for a Graph object in igraph?
Asked
Active
Viewed 130 times
1 Answers
0
Attributes in igraph are returning PyObject
s so no, you cannot type them in Cython.
However, depending on your use case, it may be useful to pre-assign the attributes to a typed c++ vector or a C array, then work on this vector/array.

Silmathoron
- 1,781
- 1
- 15
- 32
-
Thanks for the answer, I am a little confused, how pre-assign can help? isn't it the case that each time you call the attributes, python should go and check the type of attributes? – mmg Nov 27 '18 at 19:04
-
Yes, but if you're going to use them several times, you can store them first in a typed container (though that will have a more significant impact on your memory consumption) – Silmathoron Nov 27 '18 at 19:05