[Python-Dev] Rename PyUnicode_KIND_SIZE ?

Antoine Pitrou solipsis at pitrou.net
Thu Oct 6 18:03:51 CEST 2011


On Thu, 06 Oct 2011 17:52:05 +0200
Victor Stinner <victor.stinner at haypocalc.com> wrote:
> index << (kind - 1) and index * PyUnicode_CHARACTER_SIZE(str) were used 
> in unicodeobject.c. It's not easy to understand this formula

  index * PyUnicode_CHARACTER_SIZE(str)

is quite easy to understand to me.
I find it less cryptic than PyUnicode_KIND_SIZE(kind, index), actually,
and I would advocate using the former and removing the latter.

> (PyUnicode_KIND_SIZE() is also a micro-optimization, it uses shift 
> instead of multiply.)

I don't know, but I think the compiler should be able to do that for
you.
Also, I don't think PyUnicode_KIND_SIZE would be used in a critical
loop. You would use PyUnicode_READ when doing one-character-at-a-time
stuff.

Regards

Antoine.




More information about the Python-Dev mailing list