D'oh!  Sorry about the subject-line mixup, guys. :(

Also, Robert has also already pointed out maybe a
"two-key sparse -> dense map" may be all that is needed.

Another maybe-easier memory management possibility would be
to have a bit of Cython code to interpet a NumPy array *as
a hash table*, with dead slots and deleted keys and all.

So, if the association is a triple -- (int s, int t, int ix)
you could have a NumPy array that had as many 12-byte rows
as you need (assuming ints are 4 bytes), resized on demand,
etc.

That would take up basically as little space as you are going
to get with C, with the 'ix' being an index into to the NumPy
array of floats.  This would also probably yield very little
cost in malloc/free (or even just malloc) cycles.  Really,
only when the whole table grew would any memory mgmt happen.
It may well be more space efficient than this external library
with its 8 byte void pointers and such taking up extra space.

I'm not sure how easy it would be to make a table of this style
"key generic" in Cython, but the actual hash-insert/lookup
code is probably a mere 15..25 lines of Cython as a layer of
interpretation of the NumPy memory.  I may code up a little
example of an open-addressed linear probe no-deletion table
tonight if I have some time.
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to