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
088929cf
Unverified
Kaydet (Commit)
088929cf
authored
Kas 07, 2017
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
Kas 07, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-31415: Improve error handling and caching of the importtime option. (#4138)
üst
31af650e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
import.c
Python/import.c
+20
-13
No files found.
Python/import.c
Dosyayı görüntüle @
088929cf
...
@@ -1667,45 +1667,52 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
...
@@ -1667,45 +1667,52 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
}
}
}
}
else
{
else
{
static
int
ximporttime
=
0
;
/* 1 -- true, 0 -- false, -1 -- not initialized */
static
int
ximporttime
=
-
1
;
static
int
import_level
;
static
int
import_level
;
static
_PyTime_t
accumulated
;
static
_PyTime_t
accumulated
;
_Py_IDENTIFIER
(
importtime
);
_Py_IDENTIFIER
(
importtime
);
_PyTime_t
t1
=
0
,
accumulated_copy
=
accumulated
;
_PyTime_t
t1
=
0
,
accumulated_copy
=
accumulated
;
Py_XDECREF
(
mod
);
/* XOptions is initialized after first some imports.
/* XOptions is initialized after first some imports.
* So we can't have negative cache.
* So we can't have negative cache
before completed initialization
.
* Anyway, importlib._
_
find_and_load is much slower than
* Anyway, importlib._find_and_load is much slower than
* _PyDict_GetItemId
()
* _PyDict_GetItemId
WithError().
*/
*/
if
(
ximporttime
==
0
)
{
if
(
ximporttime
<
0
)
{
char
*
envoption
=
Py_GETENV
(
"PYTHONPROFILEIMPORTTIME"
);
c
onst
c
har
*
envoption
=
Py_GETENV
(
"PYTHONPROFILEIMPORTTIME"
);
if
(
envoption
!=
NULL
&&
strlen
(
envoption
)
>
0
)
{
if
(
envoption
!=
NULL
&&
*
envoption
!=
'\0'
)
{
ximporttime
=
1
;
ximporttime
=
1
;
}
}
else
{
else
{
PyObject
*
xoptions
=
PySys_GetXOptions
();
PyObject
*
xoptions
=
PySys_GetXOptions
();
PyObject
*
value
=
NULL
;
if
(
xoptions
)
{
if
(
xoptions
)
{
PyObject
*
value
=
_PyDict_GetItemId
(
value
=
_PyDict_GetItemIdWithError
(
xoptions
,
&
PyId_importtime
);
xoptions
,
&
PyId_importtime
);
}
if
(
value
==
NULL
&&
PyErr_Occurred
())
{
goto
error
;
}
if
(
value
!=
NULL
||
Py_IsInitialized
())
{
ximporttime
=
(
value
==
Py_True
);
ximporttime
=
(
value
==
Py_True
);
}
}
}
}
if
(
ximporttime
)
{
if
(
ximporttime
>
0
)
{
fputs
(
"import time: self [us] | cumulative | imported package
\n
"
,
fputs
(
"import time: self [us] | cumulative | imported package
\n
"
,
stderr
);
stderr
);
}
}
}
}
if
(
ximporttime
)
{
if
(
ximporttime
>
0
)
{
import_level
++
;
import_level
++
;
t1
=
_PyTime_GetPerfCounter
();
t1
=
_PyTime_GetPerfCounter
();
accumulated
=
0
;
accumulated
=
0
;
}
}
Py_XDECREF
(
mod
);
if
(
PyDTrace_IMPORT_FIND_LOAD_START_ENABLED
())
if
(
PyDTrace_IMPORT_FIND_LOAD_START_ENABLED
())
PyDTrace_IMPORT_FIND_LOAD_START
(
PyUnicode_AsUTF8
(
abs_name
));
PyDTrace_IMPORT_FIND_LOAD_START
(
PyUnicode_AsUTF8
(
abs_name
));
...
@@ -1717,7 +1724,7 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
...
@@ -1717,7 +1724,7 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
PyDTrace_IMPORT_FIND_LOAD_DONE
(
PyUnicode_AsUTF8
(
abs_name
),
PyDTrace_IMPORT_FIND_LOAD_DONE
(
PyUnicode_AsUTF8
(
abs_name
),
mod
!=
NULL
);
mod
!=
NULL
);
if
(
ximporttime
)
{
if
(
ximporttime
>
0
)
{
_PyTime_t
cum
=
_PyTime_GetPerfCounter
()
-
t1
;
_PyTime_t
cum
=
_PyTime_GetPerfCounter
()
-
t1
;
import_level
--
;
import_level
--
;
...
...
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