[Python-Dev] Re: .DLL vs .PYD search order

James C. Ahlstrom jim@interet.com
Thu, 02 Dec 1999 11:28:50 -0500


Guido van Rossum wrote:

> Let's assume sys.path is [A, B].  Let's assume there's a foo.py and a
> foo.dll.  If foo.py lives in A and foo.dll lives in B, then import foo
> ...

Thank you for the detailed discussion showing that sys.path is
needed so a choice can be made whether to load foo.dll or
foo.py.  As you correctly point out, a separate search path
defeats this behavior.

But I don't think the usefulness of the feature compensates for
its resultant complexity.  Specifically, it will be hard to
create this behavior in archive files.

As I envision archive files (which of course is subject to change)
they contain *.pyc files and not DLL's.  The DLL's must be in a
./DLL directory since the OS can not load them from strings.  So
if every *.pyc is in an archive file, your only choice is whether
to load all DLL's first or last.  That is, archive.pyl is either
before or after ./DLL.

If a package (probably with lots of subdirectories) author depends on
having a search path within a package which discriminates between
pyc and DLL files with equal names, then that search path plus the
existence of the DLL's must be recorded in the archive.

This is much more complicated than just an archive with all *.pyc
files entered in a dotted name space:
  foo
  foo.sub1
  foo.sub2
  foo.sub2.pkx

I would question whether equally named foo.dll and foo.py is worth it.
The alternative (which is IMHO more common) is to code the choice in
Python in the module that cares about it.

> > And what if something
> > doesn't work?  Think of Python being used as a teaching language
> > for the 8th grade.  Think of the 8th grade teacher trying to get
> > all this right.  The only thing that works is simplicity.
> 
> We will provide an installer that Just Works [tm].

OK for this case.  Not enough for Python program distribution. 

JimA