Skip to content

Isolate the itertools extension module #101277

@erlend-aasland

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

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