-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
PERF: Simplify some of loadtxt's standard converters. #19620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
a9d9668
to
78af087
Compare
Would you mind rebasing and re-profiling on main? |
|
(np.bytes_, methodcaller('encode', 'latin-1')), | ||
(np.unicode_, str), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it the case that the input to _CONVERTERS
is always a str
and never bytes
? If so, can you add a comment to _getconv
saying that the converters are for parsing data from str
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes (see also #19609). Added the comment.
Standard converters only ever get called with str inputs (loadtxt performs the required decoding); saving a bunch of runtime typechecks (in `asstr`) results in a 15-20% speedup when loadtxt()ing the corresponding types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, let's wait for CI to go green just in case.
close/reopen |
Thanks @anntzer . |
Standard converters only ever get called with str inputs (loadtxt
performs the required decoding); saving a bunch of runtime typechecks
(in
asstr
) results in a 15-20% speedup when loadtxt()ing thecorresponding types.