From 368aea88d1df378c038a20796f26dd342592c7a8 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 18 Sep 2024 13:55:52 +0200 Subject: [PATCH] Keep section for small integers --- peps/pep-0757.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/peps/pep-0757.rst b/peps/pep-0757.rst index e7648890f7a..1c13f4c2fa1 100644 --- a/peps/pep-0757.rst +++ b/peps/pep-0757.rst @@ -221,6 +221,21 @@ API:: Discard the internal object and destroy the writer instance. +Optimize import for small integers +================================== + +Proposed import API is efficient for large integers. Compared to +accessing directly Python internals, the proposed import API can have a +significant performance overhead on small integers. + +For small integers of a few digits (for example, 1 or 2 digits), existing APIs +can be used: + +* :external+py3.14:c:func:`PyLong_FromUInt64()`; +* :c:func:`PyLong_FromLong()`; +* :c:func:`PyLong_FromNativeBytes()`. + + Implementation ==============