Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
133138a2
Kaydet (Commit)
133138a2
authored
Agu 02, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #22557: Now importing already imported modules is up to 2.5 times faster.
üst
cde03fa0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
28 deletions
+61
-28
pystate.h
Include/pystate.h
+1
-0
NEWS
Misc/NEWS
+2
-0
ceval.c
Python/ceval.c
+51
-28
import.c
Python/import.c
+0
-0
pylifecycle.c
Python/pylifecycle.c
+5
-0
pystate.c
Python/pystate.c
+2
-0
No files found.
Include/pystate.h
Dosyayı görüntüle @
133138a2
...
@@ -41,6 +41,7 @@ typedef struct _is {
...
@@ -41,6 +41,7 @@ typedef struct _is {
#endif
#endif
PyObject
*
builtins_copy
;
PyObject
*
builtins_copy
;
PyObject
*
import_func
;
}
PyInterpreterState
;
}
PyInterpreterState
;
#endif
#endif
...
...
Misc/NEWS
Dosyayı görüntüle @
133138a2
...
@@ -10,6 +10,8 @@ What's New in Python 3.6.0 alpha 4
...
@@ -10,6 +10,8 @@ What's New in Python 3.6.0 alpha 4
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #22557: Now importing already imported modules is up to 2.5 times faster.
- Issue #17596: Include <wincrypt.h> to help with Min GW building.
- Issue #17596: Include <wincrypt.h> to help with Min GW building.
- Issue #27507: Add integer overflow check in bytearray.extend(). Patch by
- Issue #27507: Add integer overflow check in bytearray.extend(). Patch by
...
...
Python/ceval.c
Dosyayı görüntüle @
133138a2
...
@@ -139,6 +139,7 @@ static int maybe_call_line_trace(Py_tracefunc, PyObject *,
...
@@ -139,6 +139,7 @@ static int maybe_call_line_trace(Py_tracefunc, PyObject *,
PyThreadState
*
,
PyFrameObject
*
,
int
*
,
int
*
,
int
*
);
PyThreadState
*
,
PyFrameObject
*
,
int
*
,
int
*
,
int
*
);
static
PyObject
*
cmp_outcome
(
int
,
PyObject
*
,
PyObject
*
);
static
PyObject
*
cmp_outcome
(
int
,
PyObject
*
,
PyObject
*
);
static
PyObject
*
import_name
(
PyFrameObject
*
,
PyObject
*
,
PyObject
*
,
PyObject
*
);
static
PyObject
*
import_from
(
PyObject
*
,
PyObject
*
);
static
PyObject
*
import_from
(
PyObject
*
,
PyObject
*
);
static
int
import_all_from
(
PyObject
*
,
PyObject
*
);
static
int
import_all_from
(
PyObject
*
,
PyObject
*
);
static
void
format_exc_check_arg
(
PyObject
*
,
const
char
*
,
PyObject
*
);
static
void
format_exc_check_arg
(
PyObject
*
,
const
char
*
,
PyObject
*
);
...
@@ -2808,37 +2809,15 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
...
@@ -2808,37 +2809,15 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
}
}
TARGET
(
IMPORT_NAME
)
{
TARGET
(
IMPORT_NAME
)
{
_Py_IDENTIFIER
(
__import__
);
PyObject
*
name
=
GETITEM
(
names
,
oparg
);
PyObject
*
name
=
GETITEM
(
names
,
oparg
);
PyObject
*
func
=
_PyDict_GetItemId
(
f
->
f_builtins
,
&
PyId___import__
);
PyObject
*
fromlist
=
POP
();
PyObject
*
from
,
*
level
,
*
args
,
*
res
;
PyObject
*
level
=
TOP
();
if
(
func
==
NULL
)
{
PyObject
*
res
;
PyErr_SetString
(
PyExc_ImportError
,
"__import__ not found"
);
goto
error
;
}
Py_INCREF
(
func
);
from
=
POP
();
level
=
TOP
();
args
=
PyTuple_Pack
(
5
,
name
,
f
->
f_globals
,
f
->
f_locals
==
NULL
?
Py_None
:
f
->
f_locals
,
from
,
level
);
Py_DECREF
(
level
);
Py_DECREF
(
from
);
if
(
args
==
NULL
)
{
Py_DECREF
(
func
);
STACKADJ
(
-
1
);
goto
error
;
}
READ_TIMESTAMP
(
intr0
);
READ_TIMESTAMP
(
intr0
);
res
=
PyEval_CallObject
(
func
,
args
);
res
=
import_name
(
f
,
name
,
fromlist
,
level
);
Py_DECREF
(
level
);
Py_DECREF
(
fromlist
);
READ_TIMESTAMP
(
intr1
);
READ_TIMESTAMP
(
intr1
);
Py_DECREF
(
args
);
Py_DECREF
(
func
);
SET_TOP
(
res
);
SET_TOP
(
res
);
if
(
res
==
NULL
)
if
(
res
==
NULL
)
goto
error
;
goto
error
;
...
@@ -5158,6 +5137,50 @@ cmp_outcome(int op, PyObject *v, PyObject *w)
...
@@ -5158,6 +5137,50 @@ cmp_outcome(int op, PyObject *v, PyObject *w)
return
v
;
return
v
;
}
}
static
PyObject
*
import_name
(
PyFrameObject
*
f
,
PyObject
*
name
,
PyObject
*
fromlist
,
PyObject
*
level
)
{
_Py_IDENTIFIER
(
__import__
);
PyObject
*
import_func
,
*
args
,
*
res
;
import_func
=
_PyDict_GetItemId
(
f
->
f_builtins
,
&
PyId___import__
);
if
(
import_func
==
NULL
)
{
PyErr_SetString
(
PyExc_ImportError
,
"__import__ not found"
);
return
NULL
;
}
/* Fast path for not overloaded __import__. */
if
(
import_func
==
PyThreadState_GET
()
->
interp
->
import_func
)
{
int
ilevel
=
_PyLong_AsInt
(
level
);
if
(
ilevel
==
-
1
&&
PyErr_Occurred
())
{
return
NULL
;
}
res
=
PyImport_ImportModuleLevelObject
(
name
,
f
->
f_globals
,
f
->
f_locals
==
NULL
?
Py_None
:
f
->
f_locals
,
fromlist
,
ilevel
);
return
res
;
}
Py_INCREF
(
import_func
);
args
=
PyTuple_Pack
(
5
,
name
,
f
->
f_globals
,
f
->
f_locals
==
NULL
?
Py_None
:
f
->
f_locals
,
fromlist
,
level
);
if
(
args
==
NULL
)
{
Py_DECREF
(
import_func
);
return
NULL
;
}
res
=
PyEval_CallObject
(
import_func
,
args
);
Py_DECREF
(
args
);
Py_DECREF
(
import_func
);
return
res
;
}
static
PyObject
*
static
PyObject
*
import_from
(
PyObject
*
v
,
PyObject
*
name
)
import_from
(
PyObject
*
v
,
PyObject
*
name
)
{
{
...
...
Python/import.c
Dosyayı görüntüle @
133138a2
This diff is collapsed.
Click to expand it.
Python/pylifecycle.c
Dosyayı görüntüle @
133138a2
...
@@ -254,6 +254,11 @@ import_init(PyInterpreterState *interp, PyObject *sysmod)
...
@@ -254,6 +254,11 @@ import_init(PyInterpreterState *interp, PyObject *sysmod)
interp
->
importlib
=
importlib
;
interp
->
importlib
=
importlib
;
Py_INCREF
(
interp
->
importlib
);
Py_INCREF
(
interp
->
importlib
);
interp
->
import_func
=
PyDict_GetItemString
(
interp
->
builtins
,
"__import__"
);
if
(
interp
->
import_func
==
NULL
)
Py_FatalError
(
"Py_Initialize: __import__ not found"
);
Py_INCREF
(
interp
->
import_func
);
/* Import the _imp module */
/* Import the _imp module */
impmod
=
PyInit_imp
();
impmod
=
PyInit_imp
();
if
(
impmod
==
NULL
)
{
if
(
impmod
==
NULL
)
{
...
...
Python/pystate.c
Dosyayı görüntüle @
133138a2
...
@@ -90,6 +90,7 @@ PyInterpreterState_New(void)
...
@@ -90,6 +90,7 @@ PyInterpreterState_New(void)
interp
->
codecs_initialized
=
0
;
interp
->
codecs_initialized
=
0
;
interp
->
fscodec_initialized
=
0
;
interp
->
fscodec_initialized
=
0
;
interp
->
importlib
=
NULL
;
interp
->
importlib
=
NULL
;
interp
->
import_func
=
NULL
;
#ifdef HAVE_DLOPEN
#ifdef HAVE_DLOPEN
#if HAVE_DECL_RTLD_NOW
#if HAVE_DECL_RTLD_NOW
interp
->
dlopenflags
=
RTLD_NOW
;
interp
->
dlopenflags
=
RTLD_NOW
;
...
@@ -128,6 +129,7 @@ PyInterpreterState_Clear(PyInterpreterState *interp)
...
@@ -128,6 +129,7 @@ PyInterpreterState_Clear(PyInterpreterState *interp)
Py_CLEAR
(
interp
->
builtins
);
Py_CLEAR
(
interp
->
builtins
);
Py_CLEAR
(
interp
->
builtins_copy
);
Py_CLEAR
(
interp
->
builtins_copy
);
Py_CLEAR
(
interp
->
importlib
);
Py_CLEAR
(
interp
->
importlib
);
Py_CLEAR
(
interp
->
import_func
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment