fastnumbers 5.0: fast conversion of iterables #68
SethMMorton
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
fastnumbers
has made many changes since the 3.X branch. The 4.X branch introduced quite a few of these changes but was short-lived so we will present all of the changes from 3.X to 5.0 as if they all happened in 5.0.Major public changes
fastnumbers
is now faster overall compared to the 3.X branch (see the "Major internal changes" sections for details now) - here are some specifics:map
option or thetry_array
function, conversions of entire iterables of input are 2X faster than user-side iteration (on top of the above speed-ups).fast_*
functions are deprecated, and now have equivalent functions beginning withtry_*
try_
prefix is more indicative of the intent of the function.fast_*
functions, the two most prominent being:map
option.on_type_error
option.is*
functions are deprecated, and now have equivalent functions beginning withcheck_*
check_
prefix is more indicative of the intent of the function.is*
functions, most prominently the newstrict
option forcheck_float
that allows the ability to control whether input strings require a"."
character or not.map
option to thetry_*
functions support returning an iterator (like the built-inmap
), or returning alist
directly.map
option over iterating in Python-land.try_array
function is used to convert an iterable directly into a 1-D NumPy array.allow_underscores
is nowFalse
instead ofTrue
for all of the non-deprecated functions as a means to reduce user surprise and also slightly improve performance.Major internal changes
std::optional
,std::variant
/std::visit
and RAII have made error handling and reference counting much less error-prone - the likelihood of segfaults,SystemError
s, and memory leaks is far lower with the new code.METH_FASTCALL
) which means a large reduction of "function call overhead" compared to the 3.X branch.fast_float::from_chars
to do all floating point parsing. The ways in which this introduces speed-ups is numerous:from_chars
is correct-and-accurate for all input,fastnumbers
never has to fall back on Python's conversion function (which is not usually fast).Beta Was this translation helpful? Give feedback.
All reactions