Re: [Python-Dev] cpython: Add _PyUnicode_UTF8() and _PyUnicode_UTF8_LENGTH() macros
On Sat, 01 Oct 2011 16:53:44 +0200 victor.stinner <python-checkins@python.org> wrote:
http://hg.python.org/cpython/rev/4afab01f5374 changeset: 72565:4afab01f5374 user: Victor Stinner <victor.stinner@haypocalc.com> date: Sat Oct 01 16:48:13 2011 +0200 summary: Add _PyUnicode_UTF8() and _PyUnicode_UTF8_LENGTH() macros
* Rename existing _PyUnicode_UTF8() macro to PyUnicode_UTF8()
Wouldn't this be better called PyUnicode_AS_UTF8()?
Am 01.10.2011 17:18, schrieb Antoine Pitrou:
On Sat, 01 Oct 2011 16:53:44 +0200 victor.stinner <python-checkins@python.org> wrote:
http://hg.python.org/cpython/rev/4afab01f5374 changeset: 72565:4afab01f5374 user: Victor Stinner <victor.stinner@haypocalc.com> date: Sat Oct 01 16:48:13 2011 +0200 summary: Add _PyUnicode_UTF8() and _PyUnicode_UTF8_LENGTH() macros
* Rename existing _PyUnicode_UTF8() macro to PyUnicode_UTF8()
Wouldn't this be better called PyUnicode_AS_UTF8()?
No. _AS_UTF8 would imply that some conversion function is called. In this case, it's a pure structure accessor macro, that may give NULL if the pointer is not yet filled out. It's not called Py_AS_TYPE, but Py_TYPE; likewise not PyWeakref_AS_OBJECT, but PyWeakref_GET_OBJECT. In this case, PyUnicode_GET_UTF8 might have been an alternative. Regards, Martin
On Sat, 01 Oct 2011 17:47:26 +0200 "Martin v. Löwis" <martin@v.loewis.de> wrote:
Am 01.10.2011 17:18, schrieb Antoine Pitrou:
On Sat, 01 Oct 2011 16:53:44 +0200 victor.stinner <python-checkins@python.org> wrote:
http://hg.python.org/cpython/rev/4afab01f5374 changeset: 72565:4afab01f5374 user: Victor Stinner <victor.stinner@haypocalc.com> date: Sat Oct 01 16:48:13 2011 +0200 summary: Add _PyUnicode_UTF8() and _PyUnicode_UTF8_LENGTH() macros
* Rename existing _PyUnicode_UTF8() macro to PyUnicode_UTF8()
Wouldn't this be better called PyUnicode_AS_UTF8()?
No. _AS_UTF8 would imply that some conversion function is called.
PyBytes_AS_STRING doesn't call any conversion function, and neither did PyUnicode_AS_UNICODE.
Le samedi 1 octobre 2011 17:18:42, Antoine Pitrou a écrit :
On Sat, 01 Oct 2011 16:53:44 +0200
victor.stinner <python-checkins@python.org> wrote:
http://hg.python.org/cpython/rev/4afab01f5374 changeset: 72565:4afab01f5374 user: Victor Stinner <victor.stinner@haypocalc.com> date: Sat Oct 01 16:48:13 2011 +0200
summary: Add _PyUnicode_UTF8() and _PyUnicode_UTF8_LENGTH() macros
* Rename existing _PyUnicode_UTF8() macro to PyUnicode_UTF8()
Wouldn't this be better called PyUnicode_AS_UTF8()?
All these macro are privates and just used to have a more readable C code. For example, _PyUnicode_UTF8() just gives access to a field a structure after casting the object to the right type. We may drop "PyUnicode_" and "_PyUnicode_" prefixes if these names are confusing. Victor
participants (3)
-
"Martin v. Löwis"
-
Antoine Pitrou
-
Victor Stinner