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

Types module doesn't have a type for _abc_data #80945

Closed
isidentical opened this issue May 1, 2019 · 10 comments
Closed

Types module doesn't have a type for _abc_data #80945

isidentical opened this issue May 1, 2019 · 10 comments
Labels
3.8 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@isidentical
Copy link
Sponsor Member

BPO 36764
Nosy @methane, @serhiy-storchaka, @1st1, @isidentical
PRs
  • bpo-36764: Types module now has a ABCData type #13034
  • 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 2019-05-02.05:38:17.873>
    created_at = <Date 2019-05-01.07:22:40.195>
    labels = ['3.8', 'type-feature', 'library']
    title = "Types module doesn't have a type for _abc_data"
    updated_at = <Date 2019-05-02.05:38:17.864>
    user = 'https://github.com/isidentical'

    bugs.python.org fields:

    activity = <Date 2019-05-02.05:38:17.864>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-05-02.05:38:17.873>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2019-05-01.07:22:40.195>
    creator = 'BTaskaya'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36764
    keywords = ['patch']
    message_count = 10.0
    messages = ['341180', '341182', '341184', '341185', '341188', '341189', '341191', '341227', '341241', '341248']
    nosy_count = 4.0
    nosy_names = ['methane', 'serhiy.storchaka', 'yselivanov', 'BTaskaya']
    pr_nums = ['13034']
    priority = 'normal'
    resolution = 'rejected'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue36764'
    versions = ['Python 3.8']

    @isidentical
    Copy link
    Sponsor Member Author

    Types module doesn't have a type for _abc_data

    @SilentGhost SilentGhost mannequin added stdlib Python modules in the Lib dir 3.8 only security fixes type-feature A feature request or enhancement labels May 1, 2019
    @methane
    Copy link
    Member

    methane commented May 1, 2019

    It's implementation detail of abc. I don't want expose it in public.
    (Note that we maintain pure Python version of abc module too.)

    Why you need it in types module?
    I don't think all types exposed via types module. Only useful types should be exposed.

    @isidentical
    Copy link
    Sponsor Member Author

    I'm working on a project that is a custom byte code interpreter for some
    extended types. I needed ABCData there and i thought types module already
    has that, but i was wrong so i added.

    Isn't types module exposing some types that are implementation detail such
    as cells?

    On Wed, May 1, 2019, 12:17 PM Inada Naoki <report@bugs.python.org> wrote:

    Inada Naoki <songofacandy@gmail.com> added the comment:

    It's implementation detail of abc. I don't want expose it in public.
    (Note that we maintain pure Python version of abc module too.)

    Why you need it in types module?
    I don't think all types exposed via types module. Only useful types
    should be exposed.

    ----------
    nosy: +inada.naoki


    Python tracker <report@bugs.python.org>
    <https://bugs.python.org/issue36764\>


    @methane
    Copy link
    Member

    methane commented May 1, 2019

    I'm working on a project that is a custom byte code interpreter for some
    extended types. I needed ABCData there

    I still don't understand why you need _abc_data.

    Isn't types module exposing some types that are implementation detail such as cells?

    cell object is implementation detail of CPython core.
    While other Python implementations will not have it, it is long lived in CPython and it is stable.

    On the other hand, _abc_data is implementation detail of extension module, not interpreter.

    For example, _json.Encoder is not exposed in types module.
    If it is really needed, type of _abc_data can be exposed via _abc module.
    But I prefer keep internal data opaque unless there are reasonable reason.

    @isidentical
    Copy link
    Sponsor Member Author

    I still don't understand why you need _abc_data.
    I'm using it both for comparisons which needed to build an abstract base class and typing. Currently there are 2 ways, i need to create a dummy abc and put type() calls everywhere or i need to set a constant to my module and _abc_data is totally irrelevant with this. I dont think users want that.

    On the other hand, _abc_data is implementation detail of extension module, not interpreter.
    Abstract base classes can be called a core part of python too and when someone needs to obtain type of the struct that holds state of ABCs it shouldnt be hard, types module should expose it.

    @methane
    Copy link
    Member

    methane commented May 1, 2019

    I'm using it both for comparisons which needed to build an abstract base class and typing. Currently there are 2 ways, i need to create a dummy abc and put type() calls everywhere or i need to set a constant to my module and _abc_data is totally irrelevant with this. I dont think users want that.

    It doesn't make sense to me. Could you elaborate?

    Abstract base classes can be called a core part of python too

    abc is core part. But note that _py_abc can be used instead of _abc.
    _abc_data is used only when _abc is used as backend of abc.
    At least, your pull request doesn't work correctly when _py_abc is used.

    and when someone needs to obtain type of the struct that holds state of ABCs it shouldnt be hard, types module should expose it.

    I think it is bad idea and we don't support such usage officially at all.
    Such code doesn't work when _py_abc is used.

    @isidentical
    Copy link
    Sponsor Member Author

    It is based on default behavior of cpython. It tries to import _abc first instead of _py_abc and this type targets c implementation.

    @isidentical
    Copy link
    Sponsor Member Author

    We can try to obtain the type of ABCData and if we can't (if py_abc is
    used) we can set ABCData to NotImplemented.

    On Wed, May 1, 2019, 2:56 PM Batuhan <report@bugs.python.org> wrote:

    Batuhan <batuhanosmantaskaya@gmail.com> added the comment:

    It is based on default behavior of cpython. It tries to import _abc first
    instead of _py_abc and this type targets c implementation.

    ----------


    Python tracker <report@bugs.python.org>
    <https://bugs.python.org/issue36764\>


    @methane
    Copy link
    Member

    methane commented May 2, 2019

    You didn't explain why people not only you need it.
    "Could you elaborate?"

    Unless clear use cases, I'm strong -1 on adding it in typing module.

    @serhiy-storchaka
    Copy link
    Member

    I concur with Inada. This is a deep implementation detail. Instances of this type are not even exposed to users. And the types module should not contain all types used in CPython.

    @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.8 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants