On 01.10.2012 19:52, Peter wrote:
> I've found the map.pyx, but no hash-based implementations.
In C++11, there is an std::unsorted_map which is hash-based (std::map is
a BST). Similarly, std::unsorted_set is hash-based, whereas std::set is
BST based. The interfaces are similar, so just copy the contents of
map.pyx and replace "map" with "unsorted_map" (and ditto for set).
Also note that Pythons builtin dict and set are hash-based, but they can
only store Python objects.
If you need to hash C or C++ objects, use C++11 STL or another C or C++
hash-implementation. You can of course convert a C object to a Python
object, but it comes with a speed penalty.
Sturla