mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-118761: Improve import time for pstats
and zipfile
(#128981)
Importing `pstats` or `zipfile` is now roughly 20% faster. This is achieved by removing type annotations depending on `typing`.
This commit is contained in:
parent
ab353b31bb
commit
a95dca7b98
3 changed files with 4 additions and 4 deletions
|
@ -29,7 +29,6 @@ import re
|
|||
from enum import StrEnum, _simple_enum
|
||||
from functools import cmp_to_key
|
||||
from dataclasses import dataclass
|
||||
from typing import Dict
|
||||
|
||||
__all__ = ["Stats", "SortKey", "FunctionProfile", "StatsProfile"]
|
||||
|
||||
|
@ -69,7 +68,7 @@ class FunctionProfile:
|
|||
class StatsProfile:
|
||||
'''Class for keeping track of an item in inventory.'''
|
||||
total_tt: float
|
||||
func_profiles: Dict[str, FunctionProfile]
|
||||
func_profiles: dict[str, FunctionProfile]
|
||||
|
||||
class Stats:
|
||||
"""This class is used for creating reports from data generated by the
|
||||
|
|
|
@ -13,7 +13,6 @@ import struct
|
|||
import sys
|
||||
import threading
|
||||
import time
|
||||
from typing import Self
|
||||
|
||||
try:
|
||||
import zlib # We may need its compression method
|
||||
|
@ -606,7 +605,7 @@ class ZipInfo:
|
|||
|
||||
return zinfo
|
||||
|
||||
def _for_archive(self, archive: ZipFile) -> Self:
|
||||
def _for_archive(self, archive):
|
||||
"""Resolve suitable defaults from the archive.
|
||||
|
||||
Resolve the date_time, compression attributes, and external attributes
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Reduce import time of :mod:`pstats` and :mod:`zipfile` by up to 20%, by
|
||||
removing unnecessary imports to :mod:`typing`. Patch by Bénédikt Tran.
|
Loading…
Add table
Add a link
Reference in a new issue