Windows build importlib performance regression
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- operating-systems, performance
Línea de trabajo
Comienza reproduciendo la diferencia de tiempos en Windows 10 con los archivos proporcionados import_models.py y some_class.py usando -X importtime; después, compara las ejecuciones antes y después de python -m compileall . y con -B. Comprueba las rutas de importación de importlib y específicas de Windows implicadas en la carga del módulo. Se considera terminado cuando se haya identificado la causa de la importación en caché más lenta y se haya documentado o corregido la regresión mediante una comparación verificada.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug report
I've a file import_models.py:
import time
from ctypes import c_longdouble
from multiprocessing import Value
def import_models_func(_, import_value, exec_value):
init = time.process_time()
import some_class
import_value.value = time.process_time() - init
exec_value.value = 0
if __name__ == '__main__':
import_models_func(0, Value(c_longdouble, lock=False), Value(c_longdouble, lock=False))
The some_class.py is:
import time
class SomeClass:
__slots__ = ('a', 'b', 'c')
def __init__(self):
self.a = time.time()
self.b = self.a / 100
self.c = self.b ** 2
B = 2
for _ in range(10):
B **= 2
@property
def a_val(self):
return self.a
@a_val.getter
def a_val(self):
return self.a
@property
def b_val(self):
return self.b
@b_val.getter
def b_val(self):
return self.b
@property
def c_val(self):
return self.c
@c_val.getter
def c_val(self):
return self.c
The directory containing both files has no __pycache__. I run python -X importtime import_models.py and receive:
import time: 521 | 521 | some_class
Then I run python -m compileall . and re-run the command above, the output is:
import time: 548 | 548 | some_class
I've tried the sampling with multiprocessing governor, which is run with -B. The governor runs this scenario for 100 times, both mean and median statistics values of the timing measured mostly provide with the same results: the timing without __pycache__ is less than when the source files are pre-compiled. Which is a non-sense keeping in mind what the pre-compiled byte-code cache is built for.
I've searched for Windows-related fixes through the versions 3.9 to 3.12 and found nothing about this regression.
Linux build in a native (non-WSL, non-emulated) environment does not have such an issue (the bytecode-compiled version gets imported faster, up to 10 times, than a raw non-compiled source)
Your environment
- CPython versions tested on: Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
- Operating system and architecture: Windows 10 Enterprise 21H2 19044.2251
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 36k
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 558
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python/cpython
-
docs pending
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
stdlib type-feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
stdlib type-feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
build type-bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
stdlib topic-email type-feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Todos los issues de python/cpython
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
bancolombia/sentinel#23 ·
-
test md AbiertoCI
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100