-
Notifications
You must be signed in to change notification settings - Fork 295
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
newint performance #136
Comments
Do not specify a type can obtain a faster running speed? |
@wizzat: Thanks for your feedback! Wow, this looks pretty bad. It comes down to the
Performance would be helped by a C implementation of As @LxiaoGirl suggests, the toy script above doesn't need the ( By the way: is this the only source of performance regressions you have seen? I'd be grateful to know about any others you find (ideally as separate issues). |
Hey, thanks for looking into this! So, I end up doing a lot of numerical stuff in Python and this problem originally cropped up because of a bunch of float -> int conversions in code like this:
The natural answer is to use
So the particular block of code that I was converting from six to python-future doesn't actually rely on newint (its bounded on uint64_t) - but the "standard" set of compatibility shims ( |
In newint's try:
val = x.__int__()
except AttributeError:
val = x
else:
if not isint(val):
raise TypeError('__int__ returned non-int ({0})'.format(type(val))) When using Is this check really necessary? As far as I can see, the line Further more, if a programmer uses a class with an |
I'm seeing a HUGE performance regression in my applications since switching from six -> python-future. I've narrowed at least one new bottleneck down to the newint monkey patch.
Python 2.7 without the int import: 0.211 sec
Python 2.7 with the int import: 5.388 sec
The text was updated successfully, but these errors were encountered: