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
Uh oh!
There was an error while loading. Please reload this page.
-
fastnumbershas 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
fastnumbersis now faster overall compared to the 3.X branch (see the "Major internal changes" sections for details now) - here are some specifics:mapoption or thetry_arrayfunction, 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:mapoption.on_type_erroroption.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 newstrictoption forcheck_floatthat allows the ability to control whether input strings require a"."character or not.mapoption to thetry_*functions support returning an iterator (like the built-inmap), or returning alistdirectly.mapoption over iterating in Python-land.try_arrayfunction is used to convert an iterable directly into a 1-D NumPy array.allow_underscoresis nowFalseinstead ofTruefor 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::visitand RAII have made error handling and reference counting much less error-prone - the likelihood of segfaults,SystemErrors, 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_charsto do all floating point parsing. The ways in which this introduces speed-ups is numerous:from_charsis correct-and-accurate for all input,fastnumbersnever has to fall back on Python's conversion function (which is not usually fast).Beta Was this translation helpful? Give feedback.
All reactions