[Distutils] Dynamic linking between Python modules (was: Beyond wheels 1.0: helping downstream, FHS and more)

Chris Barker chris.barker at noaa.gov
Fri May 15 01:54:42 CEST 2015

On Thu, May 14, 2015 at 4:41 PM, Robert Collins <robertc at robertcollins.net>

> > anyway) you now have three copies of the same lib (but maybe different
> > versions) all linked into your executable. Maybe there is no downside to
> > that (I haven't had a problem yet), but it seems like a bad way to do it!
> If they are exchanging data structures, it will break at some point.
> Consider libpng; say that you have a handle to the native C struct for
> it in PIL, and you pass the wrapping Python object for it to
> Matplotlib but the struct changed between the version embedded in PIL
> and that in Matplotlib. Boom.
> If you communicate purely via Python objects that get remarshalled
> within each lib its safe (perhaps heavy on the footprint, but safe).

As far as I know -- no one tries to pass, say, libpng structure pointers
around between different python packages. You are right, that would be
pretty insane! the best you can do is pass python buffer objects around so
you are not copying data where you don't need to.

But maybe there is a use-case for passing a native lib data structure
around, in which case, yes, you'd really want the lib versions to match --
yes! I suppose if I were to do this, I'd do a run-time check on the lib
version number... not sure how else you could be safe in Python-land.

So maybe the only real downside is some wasted disk space an memory, which
are pretty cheap thee days -- but I stil l don't like it ;-)

But the linker/run time/whatever can keep track of which version of a given
function is called where?


> -Rob
> --
> Robert Collins <rbtcollins at hp.com>
> Distinguished Technologist
> HP Converged Cloud


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20150514/4ef3d020/attachment.html>

More information about the Distutils-SIG mailing list