Skip to content

Isolate the itertools extension module #101277

Description

@erlend-aasland

Feature or enhancement

Following https://github.com/ericsnowcurrently/multi-core-python/wiki/0-The-Plan we need to convert the itertools extension module to use module state.

There are multiple static global type objects:

Modules/itertoolsmodule.c - _grouper_type -
Modules/itertoolsmodule.c - accumulate_type -
Modules/itertoolsmodule.c - batched_type -
Modules/itertoolsmodule.c - chain_type -
Modules/itertoolsmodule.c - combinations_type -
Modules/itertoolsmodule.c - compress_type -
Modules/itertoolsmodule.c - count_type -
Modules/itertoolsmodule.c - cwr_type -
Modules/itertoolsmodule.c - cycle_type -
Modules/itertoolsmodule.c - dropwhile_type -
Modules/itertoolsmodule.c - filterfalse_type -
Modules/itertoolsmodule.c - groupby_type -
Modules/itertoolsmodule.c - islice_type -
Modules/itertoolsmodule.c - pairwise_type -
Modules/itertoolsmodule.c - permutations_type -
Modules/itertoolsmodule.c - product_type -
Modules/itertoolsmodule.c - repeat_type -
Modules/itertoolsmodule.c - starmap_type -
Modules/itertoolsmodule.c - takewhile_type -
Modules/itertoolsmodule.c - tee_type -
Modules/itertoolsmodule.c - teedataobject_type -
Modules/itertoolsmodule.c - ziplongest_type -

We need to convert these to heap types, add module state, and implement multi-phase init.

See also PEP-687.

I've got an old PR (#24065) that I'm planning on resurrecting. I'll re-submit it as multiple PRs; this is going to be a large change.

For this particular module, it could make sense to add a module state pointer to each type context, for easy and cheap state access.

Linked PRs

Activity

  1. sobolevn commented on Jan 24, 2023

    @sobolevn
    Member

    cc @rhettinger as the module owner.

  2. added 12 commits that reference this issue on Jan 24, 2023
  3. 42 remaining items

  4. added 11 commits that reference this issue on Feb 3, 2023
  5. added a commit that references this issue on Feb 9, 2023
  6. added a commit that references this issue on Feb 10, 2023
  7. added a commit that references this issue on Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

type-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions