Skip to content

gh-118761: Improve import time of annotationlib #132028

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

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Also defer functools import
  • Loading branch information
DavidCEllis committed Apr 2, 2025
commit 10f35b274e437ad7de98e0963e8e0ed193b9d118
11 changes: 7 additions & 4 deletions Lib/annotationlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import builtins
import enum
import functools
import keyword
import sys
import types
Expand All @@ -23,12 +22,16 @@ class _LazyImporter:
def __getattr__(self, name):
if name == "ast":
import ast
setattr(self, "ast", ast)
self.ast = ast
return ast
elif name == "_Stringifier":
from ._stringifier import _Stringifier
setattr(self, "_Stringifier", _Stringifier)
self._Stringifier = _Stringifier
return _Stringifier
elif name == "functools":
import functools
self.functools = functools
return functools
else:
raise AttributeError(
f"{self.__class__.__name__!r} object has no attribute {name!r}"
Expand Down Expand Up @@ -588,7 +591,7 @@ def get_annotations(
if hasattr(unwrap, "__wrapped__"):
unwrap = unwrap.__wrapped__
continue
if isinstance(unwrap, functools.partial):
if isinstance(unwrap, _laz.functools.partial):
unwrap = unwrap.func
continue
break
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy