Standard module implementation

Chris Rebert clp2 at rebertia.com
Sun Nov 28 21:54:44 CET 2010


On Sun, Nov 28, 2010 at 6:08 AM, candide <candide at free.invalid> wrote:
> I was wondering if all the standard module are implemented in C. For
> instance, I can't find a C implementation for the minidom xml parser under
> Python 2.6.

As was already said, no; a significant portion if not the majority of
the std lib is written in pure Python, not C.

You can usually determine how a module is implemented by looking at
the file extension of the module's __file__ attribute. For example:
$ python
Python 2.6.6 (r266:84292, Oct 12 2010, 14:31:05)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cPickle # obviously in C
>>> cPickle.__file__
'/sw/lib/python2.6/lib-dynload/cPickle.so'
>>> import pickle # pure Python version
>>> pickle.__file__
'/sw/lib/python2.6/pickle.pyc'

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list