[Pyrex] python dictionaries with unsigned long long keys and values

Sam Rushing sam-pyrex at rushing.nightmare.com
Fri Mar 16 18:34:59 UTC 2007


On Thu, 2007-03-15 at 11:03 -0400, Sam Tannous wrote:
> In that case, I can try to convert to using lists
> (as much as I hate to stop using dictionaries...
> guess I can't have simplicity & speed :-(
> 
> For speed, where (and how) should one create these 
> lists of unsigned long longs?  Just use Numeric?

If you need a fast mapping from uint64_t=>object, you could write a
little C wrapper code around an stl map, and then access it via Pyrex.
We've done this a few times at IronPort, where we make heavy use
uint64's for internal scheduler timestamps (i.e., TSC).

        //typedef std::multimap <long long, PyObject *> event_queue;
        typedef void * event_queue;
        
        event_queue * event_queue_new();
        void          event_queue_dealloc(event_queue * q);
        PyObject *    event_queue_top(event_queue * q, uint64_t * time);
        PyObject *    event_queue_pop(event_queue * q, uint64_t * time);
        int           event_queue_insert(event_queue * q, uint64_t time, PyObject * value);
        int           event_queue_delete(event_queue * q, uint64_t time, PyObject * value);
        int           event_queue_len(event_queue * q);

-Sam





More information about the Pyrex mailing list