On Sat, Jul 13, 2013 at 7:49 PM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > Ironically, Python has done the same thing for integers for many versions > too. They just didn't call it "Flexible Integer Representation", but > that's what it is. For integers smaller than 2**31, they are stored as C > longs (plus object overhead). For integers larger than 2**31, they are > promoted to a BigNum implementation that can handle unlimited digits.
Hmm. That's true of Python 2 (mostly - once an operation yields a long, it never reverts to int, whereas a string will shrink if you remove the wider characters from it), but not, I think, of Python 3. The optimization isn't there any more. At least, I did some tinkering a while ago (on 3.2, I think), so maybe it's been reinstated since. As of Python 3 and the unification of types, it's definitely possible to put that in as a pure optimization, anyhow. ChrisA -- http://mail.python.org/mailman/listinfo/python-list