Commit a94f4e7
committed
gh-148587: Pre-size and short-circuit empty in lazy modules snapshot
Pre-size the temporary dict in _PyImport_GetLazyModulesSnapshot via
_PyDict_NewPresized to avoid resizes during the inline copy. Add a fast
path that returns an empty frozendict directly when the registry has no
entries, skipping the temporary dict allocation entirely.1 parent f4f8fb2 commit a94f4e7
1 file changed
Lines changed: 27 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
| 293 | + | |
298 | 294 | | |
| 295 | + | |
299 | 296 | | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
305 | 301 | | |
306 | | - | |
307 | 302 | | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
312 | 319 | | |
313 | | - | |
314 | 320 | | |
315 | 321 | | |
316 | 322 | | |
317 | 323 | | |
318 | | - | |
| 324 | + | |
319 | 325 | | |
320 | 326 | | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
321 | 331 | | |
322 | 332 | | |
323 | 333 | | |
| |||
0 commit comments