Re: Extending collections.defaultdict
Robert Bradshaw <[email protected]> Thu, 2 Apr 2009 04:21:28 -0700
| Newsgroups | gmane.comp.python.pyrex |
|---|---|
| Message-ID | <[email protected]> |
On Apr 2, 2009, at 4:17 AM, Franck Pommereau wrote: > Hi all, > > I would like to create in Cython/Pyrex a new type by extending > collections.defaultdict class. I've found that I can extend dict by > using : > > cdef extern from "dictobject.h": > ctypedef class __builtin__.dict [object PyDictObject]: > pass > > cdef class hdict (dict): > ... > > But there is no header file such as "dictobject.h" for module > collections nor I could find one that declares defaultdict. > > Does anyone knows how I could declare the existence of defaultdict? I PyDictObject is #included into the standard Python.h file, so you could probably just get it from there. You need to make sure you have the development version of Python installed. - Robert