Python wrapper for C++ STL?

Greg Jorgensen gregj at pobox.com
Fri Dec 8 21:35:55 EST 2000


<shindich at my-deja.com> wrote

> With all due respect, what would be wrong with a definition like
> std::map<PyObject*, PyObject*>? Obviously there is no type safety here.
> But Python is not type safe.

How does that help the Python programmer? Using C++ and STL to write Python
modules is one thing, but the original question was about wrapping the STL
so it could be used from Python. STL is not a set of callable libraries that
can be wrapped--it's a collection of template definitions that are
transformed into C++ by the compiler. Once the C++ module is compiled the
STL functionality is invisible and irrelevant to the Python user.

In other words, writing a wrapper for a C library function like printf(), or
an OS function like TickCount(), makes sense. But writing a wrapper around a
compiler feature doesn't make sense. Take STL out of it and imagine writing
a wrapper around the C/C++ for loop. It's possible, but it doesn't extend
the C/C++ for loop into Python.

--
Greg Jorgensen
Deschooling Society
Portland, Oregon, USA
gregj at pobox.com





More information about the Python-list mailing list