String concatenation

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu May 12 03:43:08 EDT 2016


On Tuesday 10 May 2016 12:42, Chris Angelico wrote:

> On Tue, May 10, 2016 at 12:32 PM, Steven D'Aprano <steve at pearwood.info>
> wrote:
>> Floats are old (they go back to the first release of Python), they have
>> many quirks (x + y - x is not necessarily equal to y), and people make
>> many errors with floats. Does this mean they are deprecated? Of course
>> not.
> 
> Careful there Steven - now that cdecimal is in core, people might
> start saying that. 

They *might*, but they haven't *yet*.

And people can say all sorts of things, doesn't make them true.


> Particularly if (as is periodically requested, and
> which I think would be a good idea) Decimal literals become a thing.
> And the removal of core types HAS happened. Correct me if I'm wrong,
> but didn't the first release of Python have only the short integer
> type, and then a completely new 'long' type was added? 

The oldest Python I have installed is 0.9.1, which not only lacks the L suffix, 
but it also lacks ** for exponentiation. There's also no "long" type:

>>> n = 2
>>> for i in range(100):
... 	n = n * 2
... 
Unhandled exception: run-time error: integer overflow
Stack backtrace (innermost last):
  File "<stdin>", line 2



> Automatic
> promotion blurred the distinction, and then Python 3.0 removed the
> 'int' type and renamed 'long'. So it's theoretically possible for
> Decimal to replace float...
> 
> ... except that that would actually be a bad idea, which a lot of
> people don't realize.

Indeed. Decimal might not be old, but it does have quirks and it can certainly 
lead to errors (both misuse and rounding errors, among others). It is subject 
to the same sorts of floating point issues as binary floats.



-- 
Steve




More information about the Python-list mailing list