Message254645
For now C implementation of OrderedDict totally overrides Python implementation.
>>> import collections
>>> collections.OrderedDict.__init__
<slot wrapper '__init__' of 'collections.OrderedDict' objects>
The only way to get Python implementation of OrderedDict is to block the _collections module and reload the collections module.
>>> del sys.modules['collections']
>>> del sys.modules['collections.abc']
>>> sys.modules['_collections'] = None
>>> import collections
>>> collections.OrderedDict.__init__
<function OrderedDict.__init__ at 0xb6f6da4c>
But this also blocks collections.deque, collections.defaultdict, and the acceleration of collections.Counter.
As long as C implementation of OrderedDict still has some bugs (and I'm not sure we will have fixed all them before releasing 3.5.1), I think it would be good to have a workaround for applications that encounter one of still not fixed bugs.
I propose to keep a reference to Python implementation as collections._OrderedDict. This is not a public interface and we don't promise existing this name in future releases. This is just a way to make a workaround for the time while C implementation is not stable enough. I hope we will got rid from it in 3.7.
A workaround for an application that suffers from OrderedDict bug:
import collections
try:
collections.OrderedDict = collections._OrderedDict
except AttributeError:
pass |
|
Date |
User |
Action |
Args |
2015-11-14 08:12:48 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, eric.snow |
2015-11-14 08:12:48 | serhiy.storchaka | set | messageid: <1447488768.43.0.519685796607.issue25623@psf.upfronthosting.co.za> |
2015-11-14 08:12:48 | serhiy.storchaka | link | issue25623 messages |
2015-11-14 08:12:47 | serhiy.storchaka | create | |
|