[Python-Dev] Chose a name for a "get unicode as wide character, borrowed reference" function

Antoine Pitrou solipsis at pitrou.net
Mon Nov 21 18:04:01 CET 2011

On Mon, 21 Nov 2011 18:02:36 +0100
Victor Stinner <victor.stinner at haypocalc.com> wrote:
> Le Lundi 21 Novembre 2011 16:55:05 Antoine Pitrou a écrit :
> > > I want to rename PyUnicode_AsUnicode() and change its result type
> > > (Py_UNICODE* => wchar_t*). The result will be a "borrowed reference",
> > > ie. you don't have to free the memory, it will be done when the Unicode
> > > string will be destroyed (by Py_DECREF).
> > 
> > But this is almost the same as PyUnicode_AsWideCharString, right?
> You have to free the memory for PyUnicode_AsWideCharString().

That's why I said "almost".

I don't think it's a good idea to add this function, for two reasons:

- the unicode API is already big enough, we don't need redundant
  functions with differing refcount behaviours

- the internal wchar_t representation is certainly meant to disappear
  in the long term; adding an API which *relies* on that representation
  is silly, especially after we deliberately deprecated the Py_UNICODE



More information about the Python-Dev mailing list