-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This adds Lazy Imports to CPython 3.12 --- The following diffs from Cinder 3.10 needed to be ported to 3.12, on top of the specification in PEP-690: + D44148110 - Simplify lazy objects (always single level, less attributes) + D44220896 - Hydrate lazy objects + D44682487 - Fix tests using `set_lazy_imports(excluding=...)` + D44682641 - Split `_imp._maybe_set_parent_attribute function` for adding parent and child side effect separately + D45825709 - Save and pass builtins with lazy import objects + D49166179 - Fixes `NameError` bug + D49522414 - Reduce costs of checking if lazy imports are enabled Not needed in 3.12 (We use `EAGER_IMPORT_NAME`) + D49560412 - Handle error about invalid `__lazy_submodules__` + D49647778 - Eager child attributes in excluded modules + D52059168 - [CinderX] eliminate special case for strict modules in `_PyObject_LookupAttr` (relevant parts only) + Additionally, the environment variable `PYTHONLAZYIMPORTSALL` also turns on Lazy Imports, this also isn't in PEP-690. (`third-party/python/3.12/Python/initconfig.c:1669`) Reviewed By: itamaro Differential Revision: D52812410 fbshipit-source-id: a05888e9df8b1adf0dfa479b78ade58a99db2df3
- Loading branch information
1 parent
3978e5c
commit c925ff6
Showing
130 changed files
with
3,625 additions
and
633 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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,30 @@ | ||
/* Copyright (c) Meta, Inc. and its affiliates. All Rights Reserved */ | ||
/* File added for Lazy Imports */ | ||
|
||
#ifndef Py_INTERNAL_LAZYIMPORTOBJECT_H | ||
#define Py_INTERNAL_LAZYIMPORTOBJECT_H | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifndef Py_BUILD_CORE | ||
# error "this header requires Py_BUILD_CORE define" | ||
#endif | ||
|
||
|
||
typedef struct { | ||
PyObject_HEAD | ||
PyObject *lz_builtins; | ||
PyObject *lz_from; | ||
PyObject *lz_attr; | ||
} PyLazyImportObject; | ||
|
||
|
||
PyAPI_FUNC(PyObject *) _PyLazyImport_GetName(PyObject *lazy_import); | ||
PyAPI_FUNC(PyObject *) _PyLazyImport_New(PyObject *builtins, PyObject *from, PyObject *attr); | ||
|
||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* !Py_INTERNAL_LAZYIMPORTOBJECT_H */ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,20 @@ | ||
/* Copyright (c) Meta, Inc. and its affiliates. All Rights Reserved */ | ||
/* File added for Lazy Imports */ | ||
|
||
/* Lazy object interface */ | ||
|
||
#ifndef Py_LAZYIMPORTOBJECT_H | ||
#define Py_LAZYIMPORTOBJECT_H | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifndef Py_LIMITED_API | ||
PyAPI_DATA(PyTypeObject) PyLazyImport_Type; | ||
#define PyLazyImport_CheckExact(op) Py_IS_TYPE((op), &PyLazyImport_Type) | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* !Py_LAZYIMPORTOBJECT_H */ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.