[BUG]: iterators are needlessly slow / need an exception-free way of finishing.
Los mantenedores suelen responder en 4 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
Línea de trabajo
El issue no menciona archivos fuente ni pruebas. Empieza revisando el comportamiento documentado de pybind11 respecto a los iteradores y stop_iteration, y después reproduce el benchmark reportado de iteradores de directorios anidados. Se considerará terminado cuando se haya implementado un enfoque acordado para completar los iteradores sin excepciones y se haya validado su impacto en el rendimiento.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
2.13.1
Problem description
Currently, the only way to have an iterator finish is by throwing py::stop_iteration{}. While this is "pythonic", it also incurs huge overhead, especially on short-lived iterators.
I was benchmarking an utility I wrote in C++ that iterates over a lot of files and parses text fields from each file. The files are organized in a specific directory structure that is reflected as three layers of directory iterators, leading to a total of ~25k iterators being created.
The C++ program took 0.8s to execute, 0.47s of which were spent waiting on IO.
The equivalent Python code exposed via pybind took 4s to execute.
When profiling, I saw that 15% of time was spent in exception handling (or up to 40% when using libunwind or llvm-libunwind, bumping execution time to 6s). This seems like a low-hanging fruit compared to all the other pybind-induced overhead.
Sadly, I couldn't come up with a good way how to solve this just yet. Perhaps pybind could add a std::optional-esque container that wraps the iterator return type + a tag on whether the iterator is at it's end?
I also found no way to signal the iterator end without going throw py::stop_iteration, if I missed something obvious please yell at me.
Reproducible example code
No response
Is this a regression? Put the last known working version here if it is.
Not a regression
- Lenguaje dominante
- C++
- Estrellas
- 18k
- Forks
- 2.3k
- Merge medio
- 5 d 7 h
- PR fusionados (30 d)
- 53
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la 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 pybind/pybind11
-
triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 4 días
-
triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
pybind/pybind11#5604 · 1 comentario ·
Los mantenedores suelen responder en 4 días
-
triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 4 días
-
docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 60/100
pybind/pybind11#747 · 2 comentarios ·
Los mantenedores suelen responder en 4 días
-
array_t::at() returns a misaligned reference when the stride is not a multiple of alignof(T)Posiblemente ocupada @henryiii la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 4 días
Todos los issues de pybind/pybind11
Issues similares
-
[Bug] Windows Ghidra provider rejects a PATH-only JDK: bare `java.exe` probe fails with Win32 87Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
tenstorrent/tt-umd#4084 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
ToffelsKater/X4_VR#34 ·
-
difficulty:easy prio:low refactor
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
NatronGitHub/openfx-supportext#220 ·
Los mantenedores suelen responder en 1 día