[PYTHON MATRIX-SIG] Suggestion for pickle

Konrad Hinsen hinsen@ibs.ibs.fr
Wed, 2 Apr 1997 12:00:10 +0200


>  But NOT using the standard pickle.Pickler and pickle.Unpickler
> classes, which is sometimes annoying.
> I suggest to directly modify the original classes: just add
> 
> pickle.Unpickler = Unpickler
> pickle.Pickler = Pickler
> 
> at the end of Numeric.py

This is not really a problem with NumPy, but with pickling in general.
Subclassing is the recommended way to add extensions, but it is not
a good solution in practice.

Your solution seems good at first sight, but imagine what happens if
not only NumPy, but also other extensions do the same. You'd never
know which pickler you are using! As it is, you can choose the pickler
you want to use by importing it. It is still bad enough that no single
pickler can handle all extensions at the same time, but at least users
are aware of the problem.

The approach that cPickle uses to add extension types is a much better
one, and I hope that this will become standard at some time.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                          | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire   | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale       | Fax:  +33-4.76.88.54.94
41, av. des Martyrs                    | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France         | Nederlands/Francais
-------------------------------------------------------------------------------

_______________
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________