Sanne Korzec wrote:
> In the documentation
> http://c-algorithms.sourceforge.net/doc/hash-table_8h.html#e361c4c0256ec6c74
> 1ecfeabef33d891 , I can find:
>
> HashTable* hash_table_new ( HashTableHashFunc hash_func,
> HashTableEqualFunc equal_func
> )
>
> To create a new hash table. But I can't find were the HashTableHashFunc and
> HashTableEqualFunc are declared. The only thing I can find is in the header
> file which state:
>
> typedef unsigned long(* HashTableHashFunc)(HashTableKey value)
> typedef unsigned long(* HashTableHashFunc)(HashTableKey value)
>
> Does this mean I have to write these functions myself?
Yes.
> In c?
You can write them in Cython:
cdef unsigned long c_hash(HashTableKey value):
return huge_calculation_on(value)
> And how then do I call them from cython?
You don't. Instead, you pass the function names (i.e. pointers) into
hash_table_new().
> My guess:
>
> hashtable.pyx
"hashtable.pxd", I assume?
> cdef extern from "hash_table.h":
>
> object HashTable hash_table_new(object hash_func, object equal_func)
That won't work. You can't use Python functions as their signature won't
match the required signatures. Instead, define HashTable as a struct and
the functions as a ctypedef.
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev