Re: [Python-Dev] Question about the current implementation of str

2016-04-09 Thread Victor Stinner
2016-04-09 9:52 GMT+02:00 Victor Stinner : > But the hash is used as an heuristic to decide if a string is "immutable" or > not, the refcount is also used by the heuristic. If the string is immutable, > an operation like resize must create a new string. I'm talking about this private function: st

Re: [Python-Dev] Question about the current implementation of str

2016-04-09 Thread Serhiy Storchaka
On 09.04.16 10:52, Victor Stinner wrote: Le 9 avr. 2016 03:04, "Larry Hastings" mailto:la...@hastings.org>> a écrit : > Although the str object is immutable from Python's perspective, the C object itself is mutable. For example, for dynamically-created strings the hash field may be lazy-compute

Re: [Python-Dev] Question about the current implementation of str

2016-04-09 Thread Victor Stinner
Le 9 avr. 2016 03:04, "Larry Hastings" a écrit : > Although the str object is immutable from Python's perspective, the C object itself is mutable. For example, for dynamically-created strings the hash field may be lazy-computed and cached inside the object. Yes, the hash is computed once on dema

Re: [Python-Dev] Question about the current implementation of str

2016-04-09 Thread Nick Coghlan
On 9 April 2016 at 10:56, Larry Hastings wrote: > > > I have a straightforward question about the str object, specifically the > PyUnicodeObject. I've tried reading the source to answer the question > myself but it's nearly impenetrable. So I was hoping someone here who > understands the current

[Python-Dev] Question about the current implementation of str

2016-04-08 Thread Larry Hastings
I have a straightforward question about the str object, specifically the PyUnicodeObject. I've tried reading the source to answer the question myself but it's nearly impenetrable. So I was hoping someone here who understands the current implementation could answer it for me. Although the