Re: Immutability of Floats, Ints and Strings in Python

2016-11-28 Thread Random832
On Fri, Nov 25, 2016, at 06:33, Ned Batchelder wrote: > A Python implementation can choose when to reuse immutable objects and > when not to. Reusing a value has a cost, because the values have to > be kept, and then found again. So the cost is only paid when there's > a reasonable chance that

Re: Immutability of Floats, Ints and Strings in Python

2016-11-25 Thread Steve D'Aprano
On Fri, 25 Nov 2016 10:37 pm, Ned Batchelder wrote: > And: floats are rarely checked for equality, and very very very rarely > used as dict keys, so there's no gain by short-circuiting the equality > check. You cannot short-circuit the equality check, at least not without giving up IEEE-754

Re: Immutability of Floats, Ints and Strings in Python

2016-11-25 Thread Ned Batchelder
On Friday, November 25, 2016 at 7:17:08 AM UTC-5, BartC wrote: > On 25/11/2016 11:24, Nikunj wrote: > > > > Out of curiosity, I wanted to understand the reason behind having different > > memory location for two identical floats . This is unlike ints or strings. > > Tried googling but couldn't

Re: Immutability of Floats, Ints and Strings in Python

2016-11-25 Thread BartC
On 25/11/2016 11:24, Nikunj wrote: Out of curiosity, I wanted to understand the reason behind having different memory location for two identical floats . This is unlike ints or strings. Tried googling but couldn't find anything concrete. Any links or references would be appreciated! Do you

Re: Immutability of Floats, Ints and Strings in Python

2016-11-25 Thread Ned Batchelder
On Friday, November 25, 2016 at 6:34:00 AM UTC-5, Ned Batchelder wrote: > On Friday, November 25, 2016 at 6:24:47 AM UTC-5, Nikunj wrote: > > Hi All, > > > > Out of curiosity, I wanted to understand the reason behind having different > > memory location for two identical floats . This is unlike

Re: Immutability of Floats, Ints and Strings in Python

2016-11-25 Thread Ned Batchelder
On Friday, November 25, 2016 at 6:24:47 AM UTC-5, Nikunj wrote: > Hi All, > > Out of curiosity, I wanted to understand the reason behind having different > memory location for two identical floats . This is unlike ints or strings. > Tried googling but couldn't find anything concrete. Any links

Immutability of Floats, Ints and Strings in Python

2016-11-25 Thread Nikunj
Hi All, Out of curiosity, I wanted to understand the reason behind having different memory location for two identical floats . This is unlike ints or strings. Tried googling but couldn't find anything concrete. Any links or references would be appreciated! Example: For FLOATS: ==