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

Semi autogenerated _types module #45946

Closed
tiran opened this issue Dec 13, 2007 · 13 comments
Closed

Semi autogenerated _types module #45946

tiran opened this issue Dec 13, 2007 · 13 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@tiran
Copy link
Member

tiran commented Dec 13, 2007

BPO 1605
Nosy @gvanrossum, @pitrou, @tiran, @benjaminp
Files
  • py3k_autogen_types.patch
  • unnamed
  • 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 2010-09-18.16:33:38.994>
    created_at = <Date 2007-12-13.01:40:10.653>
    labels = ['interpreter-core', 'type-feature']
    title = 'Semi autogenerated _types module'
    updated_at = <Date 2010-09-18.16:33:38.992>
    user = 'https://github.com/tiran'

    bugs.python.org fields:

    activity = <Date 2010-09-18.16:33:38.992>
    actor = 'gvanrossum'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-09-18.16:33:38.994>
    closer = 'gvanrossum'
    components = ['Interpreter Core']
    creation = <Date 2007-12-13.01:40:10.653>
    creator = 'christian.heimes'
    dependencies = []
    files = ['8934', '9810']
    hgrepos = []
    issue_num = 1605
    keywords = ['patch']
    message_count = 13.0
    messages = ['58511', '58515', '58517', '64283', '64284', '64286', '64289', '64290', '64315', '64321', '116802', '116809', '116811']
    nosy_count = 5.0
    nosy_names = ['gvanrossum', 'pitrou', 'christian.heimes', 'benjamin.peterson', 'BreamoreBoy']
    pr_nums = []
    priority = 'low'
    resolution = None
    stage = None
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue1605'
    versions = ['Python 3.2']

    @tiran
    Copy link
    Member Author

    tiran commented Dec 13, 2007

    A while ago I've experimented with the pyvm module and a semi
    auto-generated types list. The patch adds a script that reads
    Include/*.h and adds all available PyTypeObjects to Modules/_typesmodule.c.

    The patch or script may be useful in the future.

    @tiran tiran added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Dec 13, 2007
    @gvanrossum
    Copy link
    Member

    But what about static type objects that nevertheless may be exposed to
    Python (e.g. dict_keyview?).

    @tiran
    Copy link
    Member Author

    tiran commented Dec 13, 2007

    Guido van Rossum wrote:

    But what about static type objects that nevertheless may be exposed to
    Python (e.g. dict_keyview?).

    I took care of the views a few weeks ago when I added all views and
    iterators to the header files.

    ['PyCObject',
    'bool',
    'builtin_function_or_method',
    'bytearray',
    'bytearray_iterator',
    'bytes',
    'bytes_iterator',
    'callable_iterator',
    'cell',
    'classmethod',
    'classmethod_descriptor',
    'cmpwrapper',
    'code',
    'complex',
    'dict',
    'dict_itemiterator',
    'dict_items',
    'dict_keyiterator',
    'dict_keys',
    'dict_proxy',
    'dict_valueiterator',
    'dict_values',
    'enumerate',
    'float',
    'frame',
    'frozenset',
    'function',
    'generator',
    'getset_descriptor',
    'imp.NullImporter',
    'instancemethod',
    'int',
    'iterator',
    'list',
    'list_iterator',
    'list_reverseiterator',
    'longrange_iterator',
    'member_descriptor',
    'memoryview',
    'method',
    'method_descriptor',
    'module',
    'object',
    'property',
    'range',
    'range_iterator',
    'reversed',
    'set',
    'set_iterator',
    'slice',
    'sortwrapper',
    'staticmethod',
    'stderrprinter',
    'str',
    'str_iterator',
    'super',
    'traceback',
    'tuple',
    'tuple_iterator',
    'type',
    'wrapper_descriptor',
    'zip_iterator']

    @benjaminp
    Copy link
    Contributor

    I think this is a really good idea. It's in stride with DRY, clean, and
    sure beats the Python acrobatics that types currently does to find them.

    @gvanrossum
    Copy link
    Member

    I'm still resounding -1 on this.

    Grouping types together because they happen to be implemented in C is a
    silly thing to do. Groupings should be based on usage, not on
    implementation style. I successfully argued against the inclusion of
    all metaclasses in the abc.py module. This proposal would be even more
    wrong. You might as well insist that all decorators need to be placed
    in one module.

    @benjaminp
    Copy link
    Contributor

    Okay. How about we use this like it is for 2.x, and split it out into
    different modules in Py3k. We could have execution_types and core_types.

    @gvanrossum
    Copy link
    Member

    On Fri, Mar 21, 2008 at 3:03 PM, Benjamin Peterson
    <report@bugs.python.org> wrote:

    Benjamin Peterson <musiccomposition@gmail.com> added the comment:

    Okay. How about we use this like it is for 2.x, and split it out into
    different modules in Py3k. We could have execution_types and core_types.

    No.

    @benjaminp
    Copy link
    Contributor

    No
    Well, okay. I still think we should expose these core interpreter types
    somehow, so people can identify types easily. I don't want to be forced
    to finding the type of sys._getframe to tell if I have a frame object on
    my hands. Where would you put them?

    @gvanrossum
    Copy link
    Member

    Well, okay. I still think we should expose these core interpreter types
    somehow, so people can identify types easily. I don't want to be forced
    to finding the type of sys._getframe to tell if I have a frame object on
    my hands. Where would you put them?

    Perhaps that one belongs together with sys._getframe?

    You don't seem to be getting my point (or you are purposely ignoring
    it), and this is frustrating for me. If these types must be exposed
    they should be each be exposed in a a module (new or existing) that
    defines other objects (types, functions, constants, what have you)
    with a related purpose. So maybe dict views etc. can be in
    collections. And maybe module, function, class, properties, some
    standard decorators (classmethod, staticmethod) and various types of
    methods and method wrappers can be in a module that packages code
    structures. OTOH code, frame, traceback may be more suitable for a
    low-level module (although I'm not sure about traceback, perhaps it is
    closer exceptions). Many types of iterators may best be placed in
    itertools (which defines them in the first place, many operations
    there already *are* their own type). But the iterators over the
    built-in collection types (list, dict etc.) should probably live in
    collections again.

    You see, coming up with a meaningful grouping is not all that easy --
    but that's no reason to lump them all together in a "built-in-types"
    module. Another criterion for grouping is whether the types make sense
    for other implementations like Jython, IronPython or PyPy, or not.

    I'm all for exposing these. But I'm 100% against just collecting all
    those types and putting them in a single grab-bag module.

    @benjaminp
    Copy link
    Contributor

    On Fri, Mar 21, 2008 at 11:06 PM, Guido van Rossum <report@bugs.python.org>
    wrote:

    Guido van Rossum <guido@python.org> added the comment:

    > Well, okay. I still think we should expose these core interpreter types
    > somehow, so people can identify types easily. I don't want to be forced
    > to finding the type of sys._getframe to tell if I have a frame object
    on
    > my hands. Where would you put them?

    Perhaps that one belongs together with sys._getframe?

    You don't seem to be getting my point (or you are purposely ignoring
    it), and this is frustrating for me. If these types must be exposed
    they should be each be exposed in a a module (new or existing) that
    defines other objects (types, functions, constants, what have you)
    with a related purpose. So maybe dict views etc. can be in
    collections. And maybe module, function, class, properties, some
    standard decorators (classmethod, staticmethod) and various types of
    methods and method wrappers can be in a module that packages code
    structures. OTOH code, frame, traceback may be more suitable for a
    low-level module (although I'm not sure about traceback, perhaps it is
    closer exceptions). Many types of iterators may best be placed in
    itertools (which defines them in the first place, many operations
    there already *are* their own type). But the iterators over the
    built-in collection types (list, dict etc.) should probably live in
    collections again.

    I understand your point; I just didn't understand the extent that you want
    to go to.

    You see, coming up with a meaningful grouping is not all that easy --
    but that's no reason to lump them all together in a "built-in-types"
    module. Another criterion for grouping is whether the types make sense
    for other implementations like Jython, IronPython or PyPy, or not.

    It is indeed hard.

    I'm all for exposing these. But I'm 100% against just collecting all
    those types and putting them in a single grab-bag module.


    Tracker <report@bugs.python.org>
    <http://bugs.python.org/issue1605\>


    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Sep 18, 2010

    Is this ever likely to go anywhere? My understanding is that this would be difficult to do (or have I simply misread something?). If I'm correct, wouldn't it be better to use our limited resources elsewhere?

    @pitrou
    Copy link
    Member

    pitrou commented Sep 18, 2010

    Well, the core issue is a disagreement on the way to go.

    I would agree with Benjamin's and Christian's proposal, given that it's quite practical to implement. Guido's proposal means we would have to add new modules just so that the relevant C types can be exposed "at the right place".

    The types module is generally used for low-level trickery (since most useful types are accessible from the builtin namespace), and IMO it makes sense to have a dedicated module for that.

    @gvanrossum
    Copy link
    Member

    I'm still against collecting all types in one module. Closing.

    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants