Antoine Pitrou <pit...@free.fr> added the comment: > Maybe we could consider adding an extra field to a PyLong giving its > 'small_int' value for small values, and some flag value for non-small > longs. An extra field wouldn't actually enlarge the size of a PyLong > for small values---on a 64-bit machine, a value like 23L takes 28 > bytes, for which 32 bytes will actually be allocated (since Python > always allocates in multiples of 8 bytes, I believe).
I actually had a patch for that. It declared a ob_digit[2] array instead of ob_digit[1], and ob_digit[1] contained the small int. But the patch still used the pointer comparison approach for PyLong_IS_SMALL_INT, because I think it's faster (just two comparisons). So there didn't seem to much point. Also, the pointer addition trick for addition (see BINARY_ADD) is probably faster than the more intuitive method. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10044> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com