[Tutor] Pack/Unpack hacking

Tino Dai oberoc at gmail.com
Mon Sep 7 16:42:06 CEST 2009


In general, xxx.pyc is the compiled Python bytecode for xxx.py, so
> struct.py is the source for struct.pyc.
>
> Looking at struct.py, it's entire contents is
> from _struct import *
> from _struct import _clearcache
>
> This is a pretty common idiom in the std lib for modules that are
> implemented partially or completely as C extensions - there is a
> Python wrapper, called xxx.py, which imports functions from a C
> extension called _xxx. Often there are some functions in the Python
> module; in this case, the implementation is entirely in _struct and
> struct.py is just a shell.
>
> The source for C extension modules in the std lib is in the Modules
> folder. Look for _struct.c.
>
> BTW another common convention is for modules that are implemented
> entirely in C; they will have source in Modules/xxxmodule.c, for
> example datetimemodule.c.
>
> Kent
>

Thanks Kent and TJG! I will tell you want I find. -Tino
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090907/b6cc4472/attachment.htm>


More information about the Tutor mailing list