Re: [Python-Dev] Replacement for array.array('u')?

2019-03-25 Thread Steve Dower
On 25Mar2019 0812, Martin (gzlist) wrote: On Fri, 22 Mar 2019 at 16:12, Steve Dower wrote: On 22Mar2019 0433, Antoine Pitrou wrote: The question is: why would you use a array.array() with a Windows C API? I started replying to this with a whole lot of examples, and eventually convinced

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-25 Thread Martin (gzlist) via Python-Dev
On Fri, 22 Mar 2019 at 16:12, Steve Dower wrote: > > On 22Mar2019 0433, Antoine Pitrou wrote: > > The question is: why would you use a array.array() with a Windows C API? > > I started replying to this with a whole lot of examples, and eventually > convinced myself that you wouldn't (or

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Steve Dower
On 22Mar2019 0433, Antoine Pitrou wrote: The question is: why would you use a array.array() with a Windows C API? I started replying to this with a whole lot of examples, and eventually convinced myself that you wouldn't (or shouldn't). That said, I see value in having a type for

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Antoine Pitrou
On Fri, 22 Mar 2019 16:11:45 +0200 Serhiy Storchaka wrote: > 22.03.19 13:33, Antoine Pitrou пише: > > On Fri, 22 Mar 2019 13:27:08 +0200 > > Serhiy Storchaka wrote: > >> Making it always 32 bits would be compatibility breaking change. > >> Currently array('u') represents the wchar_t string,

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Serhiy Storchaka
22.03.19 13:33, Antoine Pitrou пише: On Fri, 22 Mar 2019 13:27:08 +0200 Serhiy Storchaka wrote: Making it always 32 bits would be compatibility breaking change. Currently array('u') represents the wchar_t string, and many API on Windows require it. The question is: why would you use a

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Antoine Pitrou
On Fri, 22 Mar 2019 12:51:49 +0100 Stefan Behnel wrote: > Antoine Pitrou schrieb am 22.03.19 um 11:39: > > On Fri, 22 Mar 2019 20:31:33 +1300 Greg Ewing wrote: > >> A poster on comp.lang.python is asking about array.array('u'). > >> He wants an efficient mutable collection of unicode characters

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Stefan Behnel
Antoine Pitrou schrieb am 22.03.19 um 11:39: > On Fri, 22 Mar 2019 20:31:33 +1300 Greg Ewing wrote: >> A poster on comp.lang.python is asking about array.array('u'). >> He wants an efficient mutable collection of unicode characters >> that can be initialised from a string. > > TBH, I think anyone

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Serhiy Storchaka
22.03.19 09:45, Victor Stinner пише: Internally, CPython has a _PyUnicodeWriter which is an efficient way to create a string but appending substrings or characters. _PyUnicodeWriter changes the internal storage format depending on characters code points (ascii or latin1: 1 byte/character, BMP: 2

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Antoine Pitrou
On Fri, 22 Mar 2019 13:27:08 +0200 Serhiy Storchaka wrote: > 22.03.19 09:31, Greg Ewing пише: > > A poster on comp.lang.python is asking about array.array('u'). > > He wants an efficient mutable collection of unicode characters > > that can be initialised from a string. > > > > According to the

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Serhiy Storchaka
22.03.19 09:31, Greg Ewing пише: A poster on comp.lang.python is asking about array.array('u'). He wants an efficient mutable collection of unicode characters that can be initialised from a string. According to the docs, the 'u' code is deprecated and will be removed in 4.0, but no alternative

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Inada Naoki
FYI, I have created issue on bugs.python.org about adding deprecation warning for array('u'). https://bugs.python.org/issue36299 I created PR to change Py_UNICODE to Py_UCS4, instead of deprecate it. https://github.com/python/cpython/pull/12497 Then, I found same change had made and reverted in

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Antoine Pitrou
On Fri, 22 Mar 2019 20:31:33 +1300 Greg Ewing wrote: > A poster on comp.lang.python is asking about array.array('u'). > He wants an efficient mutable collection of unicode characters > that can be initialised from a string. TBH, I think anyone trying to use array.array should be directed to

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Steven D'Aprano
On Fri, Mar 22, 2019 at 08:31:33PM +1300, Greg Ewing wrote: > A poster on comp.lang.python is asking about array.array('u'). > He wants an efficient mutable collection of unicode characters > that can be initialised from a string. > > According to the docs, the 'u' code is deprecated and will be

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Inada Naoki
On Fri, Mar 22, 2019 at 4:38 PM Greg Ewing wrote: > > A poster on comp.lang.python is asking about array.array('u'). > He wants an efficient mutable collection of unicode characters > that can be initialised from a string. > > According to the docs, the 'u' code is deprecated and will be >

Re: [Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Victor Stinner
Hi, Internally, CPython has a _PyUnicodeWriter which is an efficient way to create a string but appending substrings or characters. _PyUnicodeWriter changes the internal storage format depending on characters code points (ascii or latin1: 1 byte/character, BMP: 2 b/c, full UCS: 4 b/c). I tried

[Python-Dev] Replacement for array.array('u')?

2019-03-22 Thread Greg Ewing
A poster on comp.lang.python is asking about array.array('u'). He wants an efficient mutable collection of unicode characters that can be initialised from a string. According to the docs, the 'u' code is deprecated and will be removed in 4.0, but no alternative is suggested. Why is this being