Author yahya-abou-imran
Recipients yahya-abou-imran
Date 2018-01-01.06:09:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1514786965.88.0.467229070634.issue32473@psf.upfronthosting.co.za>
In-reply-to
Content
From python-ideas:
https://mail.python.org/pipermail/python-ideas/2017-December/048504.html

In python 2.7, ABCs's caches and registries are sets. But in python 3.6 they are WeakSet.
In consequence, the output of _dump_registry() is almost useless:

>>> from collections import abc
>>> abc.Iterator._dump_registry()
Class: collections.abc.Iterator
Inv.counter: 40
_abc_cache: <_weakrefset.WeakSet object at 0x7f4b58fe2668>
_abc_negative_cache: <_weakrefset.WeakSet object at 0x7f4b53283780>
_abc_negative_cache_version: 40
_abc_registry: <_weakrefset.WeakSet object at 0x7f4b58fe2630>

We could convert them into a regular set before printing:

if isinstance(value, WeakSet):
    value = set(value)

The result:

>>> abc.Iterator._dump_registry()
Class: collections.abc.Iterator
Inv.counter: 40
_abc_cache: {<class 'dict_valueiterator'>, <class 'bytearray_iterator'>, <class 'tuple_iterator'>, <class 'dict_itemiterator'>, <class 'dict_keyiterator'>, <class 'str_iterator'>, <class 'zip'>, <class 'set_iterator'>, <class 'list_reverseiterator'>, <class 'range_iterator'>, <class 'longrange_iterator'>, <class 'list_iterator'>, <class 'bytes_iterator'>}
_abc_negative_cache: set()
_abc_negative_cache_version: 40
_abc_registry: set()
History
Date User Action Args
2018-01-01 06:09:25yahya-abou-imransetrecipients: + yahya-abou-imran
2018-01-01 06:09:25yahya-abou-imransetmessageid: <1514786965.88.0.467229070634.issue32473@psf.upfronthosting.co.za>
2018-01-01 06:09:25yahya-abou-imranlinkissue32473 messages
2018-01-01 06:09:25yahya-abou-imrancreate