Python C extension providing... Python's own API?

Adam Atlas adam at atlas.st
Tue Mar 27 03:02:39 CEST 2007


On Mar 26, 4:55 pm, "Matimus" <mccre... at gmail.com> wrote:
> I think that is what the "code" module is for. Maybe not exactly what
> you were expecting, but the capability you describe is already there.
> Being able to access its own interpreter is one of the things that
> makes Python a  dynamic language.

That's not really what I'm after. Believe me, I've searched the
standard library in length and breadth. :) The `code` module runs in
the same interpreter, basically executing as though it were just a
separate module (except interactively). What I'm interested in is
accessing Python's C API for CREATING interpreters -- i.e. what
mod_python or anything else embedding the Python interpreter would do.
Creating a whole environment, not just a module; it has its own `sys`
parameters, its own `__builtin__`, and so on, so you can safely mess
with those without changing them in the parent interpreter.

So far, I've tried ctypes, and it doesn't work; then I noticed the
docs said it wouldn't anyway. But I think I'll try writing a C
extension module. This could be interesting for sandboxing &c.




More information about the Python-list mailing list