On Fri, Jun 6, 2008 at 11:01 AM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On Thu, Jun 5, 2008 at 8:45 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: >> Does anyone actually need an int lookalike with binary methods but >> cannot just inherit from int? > > Does anyone actually need an int lookalike with operations like +, - > etc. but cannot just inherit from int? If the answer is yes, is there > a compelling reason why they wouldn't want to support binary methods > as well?
Yes, there's a use case for implementing long integers as arrays of decimal digits -- addition is roughly as efficient as for binary integers (x86 chips still have instructions to help with that), and emitting as decimal digits is MUCH more efficient of course -- so if I/O in decimal form is the most common operation, with a little arithmetic (particularly sums), you could gain performance; binary operations, however, would be as inefficient as decimal form conversion is for ordinary binary ints, and not needed for the typical applications that would use these "decimal coded integers" (accounting), so why not save the implementer of such an extension from having to write that unneeded and slow extra code? Alex _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com