Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Introduce a new set-based function stdlib_modules() #174

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

Open
AA-Turner wants to merge 3 commits into pypi:main
base: main
Choose a base branch
Loading
from AA-Turner:sorted

Conversation

Copy link
Contributor

@AA-Turner AA-Turner commented Aug 18, 2025

Follows on from #167, cc @woodruffw @miketheman

We introduce a new frozenset-based API, stdlib_modules(), that takes the place of stdlib_list for loading the package data. Due to this, we can simplify the remaining functions by using sorted() in stdlib_list and removing the lru_cache decorator.

A

Copy link
Member

Thanks @AA-Turner! Makes sense to me.

Do you have thoughts/opinions on deprecating the stdlib_list() API? I'd be okay with us marking it as deprecated and then removing it in the N+1 minor release (or maybe finally going 1.0?), but I'm curious what you think.

Copy link
Contributor Author

Do you have thoughts/opinions on deprecating the stdlib_list() API? I'd be okay with us marking it as deprecated and then removing it in the N+1 minor release (or maybe finally going 1.0?), but I'm curious what you think.

I would support deprecating, yes. I can't think of any good reasons to require a sorted list as first-class API. sys.stdlib_module_names is a set, other similar packages also use a frozenset approach.

The outlier is sys.builtin_module_names which is a tuple(!) for reasons of seeming prehistory -- the set type didn't yet exist.

finally going 1.0

I'd also support this, version numbers are unending in their supply. If anything goes badly wrong, it would be fun to finally see a package use the PEP 440 Epoch marker!

A

woodruffw reacted with heart emoji

Copy link
Member

warehouse currently uses stdlib_list here:
https://github.com/pypi/warehouse/blob/2ecf83f9938573cc89b3e79991b934d27016018f/warehouse/packaging/services.py#L60-L73

Probably a relatively trivial replacement, but it'd be good to understand what API is better before it's removed.

Copy link
Member

woodruffw commented Aug 18, 2025
edited
Loading

warehouse currently uses stdlib_list here: pypi/warehouse@2ecf83f/warehouse/packaging/services.py#L60-L73

Probably a relatively trivial replacement, but it'd be good to understand what API is better before it's removed.

If I'm reading this right, the two should have equivalent characteristics in this case: itertools.chain should work just as well over a frozenset. But this is indeed a good reason to not do the deprecation immediately, and instead add this API and see what happens when we try and migrate PyPI to it 🙂

AA-Turner reacted with thumbs up emoji

Copy link
Contributor Author

@miketheman the other relevant part is here:

 if canonicalize_name(name) in STDLIB_PROHIBITED:
 raise ProjectNameUnavailableStdlibError()

This could probably be replaced by the proposed API in #120, because (I assume) all warehouse wants to check is that the proposed name does not attempt to inhabit any part of the stdlib namespace. 'collections.tin_of_spam' in STDLIB_PROHIBITED would currently be False!

Proof of concept: https://pypi.org/project/collections.tin_of_spam/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@woodruffw woodruffw woodruffw approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /