[Python-ideas] {Python-ideas] C-API exposure

Guido van Rossum guido at python.org
Tue Mar 29 19:53:10 CEST 2011

On Tue, Mar 29, 2011 at 10:47 AM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> As I have been toying around with a few things, I have noticed that the
> C-API provides a lot more functionality than is exposed in Python.  Much of
> the functionality can be reproduced one way or another.  However, I was
> wondering if it would be feasible (and tractable) to expose every bit of the
> C-API in python.

> If it happened, then everything in there could be written in pure python
> relative to all the other exposed pieces.  This would allow easier
> prototyping of new language features.  It would not be practical from a
> performance standpoint for most stuff, but it would help people understand
> how python works underneath.  As well, exposing all the pieces would provide
> a way to test the C-API completely from pure python.

> While I see several good things, I also see the size of the task.  Just
> exposing the C-API would be a feat.  On top of that, emulating the innards
> of each piece in pure python using the other exposed pieces would be a big
> job.  Would it be worth it?  Would it expose things we actually don't want
> exposed?

> I think it would be really cool, but half the time that is a good warning
> sign.

Well, would it really be pure Python? You should carefully consider
how portable that "pure Python" code you propose to write would be to
alternate Python implementations like Jython, IronPython or PyPy.

It also sounds like you're about to independently discover Cython.

Finally, can you be specific? Do you have some examples of C-APIs that
could be exposed? What would be gained?

--Guido van Rossum (python.org/~guido)

More information about the Python-ideas mailing list