[Networkit] Containers of libc.stdint types cannot be converted from Python

Hamann, Michael (ITI) michael.hamann at kit.edu
Wed Jul 23 10:10:10 CEST 2014


Hi,

I have a problem using the integer definitions like uint64_t from 
libc.stdint as template arguments for c++ container types. When using 
something like vector[uint64_t] as return value, there is no problem. 
The vector is automatically converted to its Python equivalent. However 
when using the same type as argument value in a function, this 
conversion doesn't work. Instead (here for a set instead of a vector) I 
get an error message like

Error compiling Cython file:
------------------------------------------------------------
...
cdef extern from *:
     ctypedef uint64_t X 'uint64_t'
             ^
------------------------------------------------------------

set.from_py:110:13: 'uint64_t' is not a type identifier

The exactly same code works when using "unsigned long" instead of 
"uint64_t".

For a concrete example refer to 
https://algohub.iti.kit.edu/parco/NetworKit/NetworKit/files/7b8e87d3688afc9a225185206000dcf91a6354ad/src/python/_NetworKit.pyx#L808 
- we would like to use "uint64_t" (or rather a ctypedef that refers to 
uint64_t) as argument here. The problem persists when the conversion is 
done explicitly in the cdef class (using <node[uint64_t]> 
degreeSequence) and also when the argument type is already declared in 
the method of the cdef class.

A similar problem was already mentioned 8 months ago in this topic: 
https://groups.google.com/forum/#!topic/cython-users/CFlfbOB-wjM

Is this a bug in Cython or is there anything we can do in order to avoid 
this problem? I am using Cython version 0.20.2.

Thank you!

Michael



More information about the NetworKit mailing list