Re: How does python know?

2014-02-12 Thread Tobiah
On 02/12/2014 12:17 PM, Tobiah wrote: I do this: a = 'lasdfjlasdjflaksdjfl;akjsdf;kljasdl;kfjasl' b = 'lasdfjlasdjflaksdjfl;akjsdf;kljasdl;kfjasl' print print id(a) print id(b) And get this: True 140329184721376 140329184721376 This works for longer strings. Does python compare a new

Re: How does python know?

2014-02-12 Thread Chris Angelico
On Thu, Feb 13, 2014 at 7:17 AM, Tobiah t...@tobiah.org wrote: This works for longer strings. Does python compare a new string to every other string I've made in order to determine whether it needs to create a new object? No, it doesn't; but when you compile a module (including a simple

Re: How does python know?

2014-02-12 Thread Gary Herron
On 02/12/2014 12:17 PM, Tobiah wrote: I do this: a = 'lasdfjlasdjflaksdjfl;akjsdf;kljasdl;kfjasl' b = 'lasdfjlasdjflaksdjfl;akjsdf;kljasdl;kfjasl' print print id(a) print id(b) And get this: True 140329184721376 140329184721376 This works for longer strings. Does python compare a new

Re: How does python know?

2014-02-12 Thread Dave Angel
Tobiah t...@tobiah.org Wrote in message: On 02/12/2014 12:17 PM, Tobiah wrote: I do this: a = 'lasdfjlasdjflaksdjfl;akjsdf;kljasdl;kfjasl' b = 'lasdfjlasdjflaksdjfl;akjsdf;kljasdl;kfjasl' print print id(a) print id(b) And get this: True 140329184721376 140329184721376 This

Re: How does python know?

2014-02-12 Thread Roy Smith
In article lFQKu.455927$cz.440...@fx31.iad, Tobiah t...@tobiah.org wrote: I do this: a = 'lasdfjlasdjflaksdjfl;akjsdf;kljasdl;kfjasl' b = 'lasdfjlasdjflaksdjfl;akjsdf;kljasdl;kfjasl' print print id(a) print id(b) And get this: True 140329184721376 140329184721376 This