Add __reduce__() method to BitwiseOperator and _NamedInt.
authorW. Trevor King <wking@drexel.edu>
Thu, 15 Mar 2012 02:55:45 +0000 (22:55 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 15 Mar 2012 02:55:45 +0000 (22:55 -0400)
commit520f82497804b26df7624f44dfedad9303ebe6d9
tree40034221290cc08938bafbe98c1991fa0c48f964
parent093ec301aa38f59bb64b37a0ddaa85e4f993c633
Add __reduce__() method to BitwiseOperator and _NamedInt.

This makes it possible to successfully pickle and deepcopy instances
of these types [1,2].  This gets the

  TRIG_SRC.now == copy.deepcopy(TRIG_SRC.now)

doctest working, which I needed to successfully dump h5config
ChoiceConfig objects that use _Enum choices [3].

For example, the newly fixed pypiezo.config.ChannelConfig [4] uses the
AREF enum values as possible choices for it's `analog-reference`
setting.  h5config makes deepcopies of mutable objects to avoid
confusion if the mutable is changed externally.  It then compares the
deepcopies with uncopied values.  Now that deepcopying works for
_NamedInts, the h5config behavior will work.

[1] http://docs.python.org/library/pickle.html#pickling-and-unpickling-extension-types
[2] http://docs.python.org/library/copy.html
[3] http://pypi.python.org/pypi/h5config/
[4] http://pypi.python.org/pypi/pypiezo/
pycomedi/constant.pyx