[Cython] What now?
stefan_ml at behnel.de
Thu Aug 18 07:32:23 CEST 2011
Stefano, 11.08.2011 16:24:
> now that I've nailed Cython code, I'd like to get into something more funny.
> Currently, I'm working on a set of macros to seamlessy integrate Cython into
> CMake build process (in fact, I love CMake). But, I'd like to work also on
> something more essential, so...
Here's something truly essential that's been on our TODO list for ages, and
it's not even that hard to do, given today's infrastructure (inline
functions in .pxd files, function signature overloading and all that).
Basically, the idea is to use a .pxd for existing Python modules
(especially stdlib modules) and to override *some* names in it with fast C
- for each normally "import"-ed module (except for relative imports),
search for a corresponding .pxd file in both the PYTHONPATH and under
- if found, build a scope for it that falls through to the scope of the
normally imported Python module, but looks up names in the .pxd namespace
For testing, write a cpython/math.pxd that contains replacements for *some*
of the functions and constants in Python's math module.
There is obviously a bit more to it than the short wrap-up above. For
example, if none of the signatures of a function in the .pxd matches, it
would have to fall through to the module as well. That isn't all that easy
to accomplish with just a name lookup. But it's also not strictly required
for an initial implementation, it would just mean that your math.pxd
implementation would have to be provide a complete set of signatures for
the functions it offers. I think the math module is particularly friendly here.
More information about the cython-devel