Difference between Win-dll's and pyd's??

James C. Ahlstrom jim at interet.com
Tue May 11 10:18:16 EDT 1999


"Thomas S. Strinnhed" wrote:
> Now for the questions:
>  I suspect the .pyd-files to be "Python-dll's". Right??
>  No:    If not, what are they, and how to use them.
>  Yes:   If so, can I substitute .pyd's for win-dll's and vice versa
>         or can they be used in any other ways??

Yes, .pyd files are dll's.  But there are a few differences.  If you
have a DLL named foo.pyd, then it must have a function initfoo().  You
can then write Python "import foo", and Python will search for foo.pyd
(as well as foo.py, foo.pyc) and if it finds it, will attempt to call
initfoo() to initialize it.  You do not link your .exe with foo.lib,
as that would cause Windows to require the DLL to be present.

Note that the search path for foo.pyc is PYTHONPATH, not the same as
the path that Windows uses to search for foo.dll.  Also, foo.pyd need
not be present to run your program, whereas if you linked your program
with a dll, the dll is required.  Of course, foo.pyd is required if
you want to say "import foo".  In a dll, linkage is declared in the
source
code with __declspec(dllexport).  In a .pyd, linkage is defined in a
list
of available functions.

Jim Ahlstrom

Jim




More information about the Python-list mailing list