Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The distinction is probably still there but slightly more hidden from view. It's a good optimization, no reason to throw it out.

It would take some prodding around to find out.



All python ints/longs are boxed (there's a cache for like -5 to 256). The interpreter often checks if the digit count is 1, in which case it can fall into basic integer addition of C. This is an implementation detail tho; if I do type(x) I shouldn't have to check for both int & long. So they store that information as part of the object type, rather than in the type of the object

In the past some have implemented tagged integers for Python, good benchmarking results but the devs argue 'Good Python code should be more symbolic; it shouldn't be doing too much integer math' which also comes up where the interpreter doesn't implement specialized code for floats, instead they argue that if you need fast floating point you should be using numpy or a C extension

Tagged ints: https://mail.python.org/pipermail/python-dev/2004-July/04613...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: