[issue45213] Frozen modules are looked up using a linear search.

2021-09-24 Thread Dong-hee Na
Dong-hee Na added the comment: > Then we can at least bail out of the loop early, and one day someone could > make it a binary search. I like this idea if we can guarantee the order :) -- ___ Python tracker __

[issue45213] Frozen modules are looked up using a linear search.

2021-09-23 Thread Steve Dower
Steve Dower added the comment: Could we add a compile-time requirement (most likely checked in tests, rather than at build) that _PyImport_FrozenModules be sorted? Then we can at least bail out of the loop early, and one day someone could make it a binary search. -- nosy: +steve.dowe

[issue45213] Frozen modules are looked up using a linear search.

2021-09-22 Thread Eric Snow
Eric Snow added the comment: On Wed, Sep 22, 2021 at 7:12 AM Dong-hee Na wrote: > I thought about the Trie implementation for this case. On Wed, Sep 22, 2021 at 7:22 AM Marc-Andre Lemburg wrote: > Perhaps a frozen dict could be used instead of the linear search. > > This could then also be m

[issue45213] Frozen modules are looked up using a linear search.

2021-09-22 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Perhaps a frozen dict could be used instead of the linear search. This could then also be made available as sys.frozen_modules for inspection by applications and tools such as debuggers or introspection tools trying to find source code (and potentially f

[issue45213] Frozen modules are looked up using a linear search.

2021-09-22 Thread Dong-hee Na
Dong-hee Na added the comment: I thought about the Trie implementation for this case. But as Eric said, it can be overkilling for this time. -- nosy: +corona10 ___ Python tracker

[issue45213] Frozen modules are looked up using a linear search.

2021-09-20 Thread Eric Snow
Eric Snow added the comment: On Mon, Sep 20, 2021 at 12:55 AM Raymond Hettinger wrote: > If you close this out, consider adding a prominent comment so that the issue > will be on the minds of people looking at this code. Good idea! -- ___ Python

[issue45213] Frozen modules are looked up using a linear search.

2021-09-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: If you close this out, consider adding a prominent comment so that the issue will be on the minds of people looking at this code. -- nosy: +rhettinger status: pending -> open ___ Python tracker

[issue45213] Frozen modules are looked up using a linear search.

2021-09-15 Thread Eric Snow
Eric Snow added the comment: Realistically, I doubt this will ever be a problem. The list of frozen modules is fairly small and the loop in the C code is a lightweight. So it isn't that big of a deal relative to the other costs involved in import. Even if the number of frozen modules grow

[issue45213] Frozen modules are looked up using a linear search.

2021-09-15 Thread Eric Snow
New submission from Eric Snow : When looking up a frozen modules, we loop over the array of frozen modules until we find a match (or don't). See find_frozen() in Python/import.c. The frozen importer sits right after the builtin importer and right before the file-based importer. This means