FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-118761: Improve import time for `pstats` and `zipfile` by removing imports to `typing` by picnixz · Pull Request #128981 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
3 changes: 1 addition & 2 deletions Lib/pstats.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
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"]

Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Lib/zipfile/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import sys
import threading
import time
from typing import Self

try:
import zlib # We may need its compression method
Expand Down Expand Up @@ -606,7 +605,7 @@ def from_file(cls, filename, arcname=None, *, strict_timestamps=True):

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
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -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.

Back | FazBrowse Home | New Git URL