Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readibility of ABCMeta._dump_registry() #76654

Closed
yahya-abou-imran mannequin opened this issue Jan 1, 2018 · 3 comments
Closed

Readibility of ABCMeta._dump_registry() #76654

yahya-abou-imran mannequin opened this issue Jan 1, 2018 · 3 comments
Labels
3.7 (EOL) end of life type-feature A feature request or enhancement

Comments

@yahya-abou-imran
Copy link
Mannequin

yahya-abou-imran mannequin commented Jan 1, 2018

BPO 32473
Nosy @methane, @ilevkivskyi, @yahya-abou-imran
PRs
  • bpo-32473: Improve ABCMeta._dump_registry() readability #5091
  • [3.6] bpo-32473: Improve ABCMeta._dump_registry() readability (GH-5091) #5163
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-01-12.10:48:15.601>
    created_at = <Date 2018-01-01.06:09:25.865>
    labels = ['type-feature', '3.7']
    title = 'Readibility of ABCMeta._dump_registry()'
    updated_at = <Date 2018-01-12.10:48:15.600>
    user = 'https://github.com/yahya-abou-imran'

    bugs.python.org fields:

    activity = <Date 2018-01-12.10:48:15.600>
    actor = 'methane'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-01-12.10:48:15.601>
    closer = 'methane'
    components = []
    creation = <Date 2018-01-01.06:09:25.865>
    creator = 'yahya-abou-imran'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32473
    keywords = ['patch']
    message_count = 3.0
    messages = ['309321', '309840', '309847']
    nosy_count = 3.0
    nosy_names = ['methane', 'levkivskyi', 'yahya-abou-imran']
    pr_nums = ['5091', '5163']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue32473'
    versions = ['Python 3.6', 'Python 3.7']

    @yahya-abou-imran
    Copy link
    Mannequin Author

    yahya-abou-imran mannequin commented Jan 1, 2018

    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()

    @yahya-abou-imran yahya-abou-imran mannequin added 3.7 (EOL) end of life type-feature A feature request or enhancement labels Jan 1, 2018
    @methane
    Copy link
    Member

    methane commented Jan 12, 2018

    New changeset ae12f5d by INADA Naoki (yahya-abou-imran) in branch 'master':
    bpo-32473: Improve ABCMeta._dump_registry() readability (GH-5091)
    ae12f5d

    @methane
    Copy link
    Member

    methane commented Jan 12, 2018

    New changeset a91662a by INADA Naoki (Miss Islington (bot)) in branch '3.6':
    bpo-32473: Improve ABCMeta._dump_registry() readability (GH-5091)
    a91662a

    @methane methane closed this as completed Jan 12, 2018
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant