Re-benchmark num_digits_fast against num_digits_faster after the boundary fix
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Documentación
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- performance
Línea de trabajo
Lee maths/number_of_digits.py y compara las tres implementaciones. Luego ejecuta benchmark() cuando se haya fusionado PR #15761. Registra los resultados y actualiza el docstring o los nombres de las funciones para que coincidan con ellos, incluido el límite de dígitos documentado para la conversión de enteros a cadenas; el trabajo estará terminado cuando el benchmark y la explicación reflejen las ventajas y desventajas medidas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Feature description
Feature description
PR #15761 (fixing #15754) makes num_digits_fast in maths/number_of_digits.py exact by adding a correction step after math.log10. The correction computes 10 ** (digits - 1) and 10**digits, which are big-integer powers and add cost for large inputs.
In a quick local timing on 2**100 (200,000 calls with timeit), the corrected approach took about 0.148 s, versus about 0.035 s for len(str(abs(n))). So the function named "fast" may no longer be the fastest of the three.
Proposed follow-up, once #15761 is merged:
- Re-run
benchmark()in the file and record the results for all three functions. - If
num_digits_fastis no longer faster, update its docstring to say it is a log10-based approach, or rename or reorder the functions so the names match the results. - Add a note on the int-to-string length limit:
len(str(n))raises ValueError for ints above about 4300 digits by default in Python 3.11+, while the log10 approach avoids it. That is a reason to keep it.
I'm happy to open a PR for the docstring and benchmark update after #15761 lands.
- Lenguaje dominante
- Python
- Estrellas
- 226k
- Forks
- 51.3k
- Merge medio
- 8 h 58 min
- PR fusionados (30 d)
- 4
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- 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 TheAlgorithms/Python
-
binomial_distribution overflows at 171 trials even when the result is representablePosiblemente ocupada @landfvit la tomó hace 19 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
TheAlgorithms/Python#15656 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
continued_fraction uses float division, producing invalid terms for large integers and raising OverflowErrorPosiblemente ocupada @trleo la tomó hace 19 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
TheAlgorithms/Python#15655 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
ciphers/base32.py and ciphers/base85.py encode Unicode code points instead of bytes: output diverges from the spec for non-ASCII, round-trips corrupt chars >= U+0400, arbitrary bytes crashPosiblemente ocupada @Nate-br la tomó hace 21 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
TheAlgorithms/Python#15636 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
ciphers/des_ecb.py: encrypt/decrypt silently corrupts any character above U+00FF (round-trip fails)Posiblemente ocupada @mohammedanasnakhuda la tomó hace 21 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
TheAlgorithms/Python#15634 ·
Los mantenedores suelen responder en 1 día
-
other/password.py: alternative_password_generator ignores the requested length when the required characters exceed itPosiblemente ocupada @raaj-2222 la tomó hace 22 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
TheAlgorithms/Python#15633 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de TheAlgorithms/Python
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
521xueweihan/HelloGitHub#4385 ·
-
🐛 bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
pdm-project/pdm#4012 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
pollen-robotics/reachy_mini_conversation_app#611 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 91/100
aws-samples/sample-per-model-bedrock#913 ·
Los mantenedores suelen responder en 1 día
-
lesson-submission pending-review
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Ikalus1988/MisakaNet#5115 ·
Los mantenedores suelen responder en 1 día