[Python-Dev] an unimportant question, ...
Michael Foord
fuzzyman at voidspace.org.uk
Sun Mar 22 18:38:54 CET 2009
Christian Tismer wrote:
> ... but I'm curious.
>
> Hi Guido,
>
> while working on Psyco, I stumbled over a log entry in modsupport.h:
>
>>
>> 19-Aug-2002 GvR 1012 Changes to string object struct for
>> interning changes, saving 3 bytes.
>>
>
> The change to stringobject was this (rev. 28308):
>
> Before:
>> typedef struct {
>> PyObject_VAR_HEAD
>> long ob_shash;
>> PyObject *ob_sinterned;
>> char ob_sval[1];
>> } PyStringObject;
>
> After:
>> typedef struct {
>> PyObject_VAR_HEAD
>> long ob_shash;
>> int ob_sstate;
>> char ob_sval[1];
>> } PyStringObject;
>
> Now, the internals are very clear to me. What I don't understand
> is where the three saved bytes should be.
>
> Thinking of the time where this change was made, I cannot imagine
> that this comment was about the size diff between pointer and int,
> and if this was meant, I still don't get how this could save three
> bytes?
>
> With unaligned ob_sval, structure packing and ob_sstate being
> unsigned char one could save 3 bytes, but we don't do that.
>
> Well, as said, this is no important question. I am just asking
> myself what I don't see here, or if the comment is just sub-optimal :-)
>
At Resolver we've found it useful to short-circuit any doubt and just
refer to comments in code as 'lies'. :-)
Michael
> all the best -- chris
>
>
> p.s.: won't make it to PyCon this time, see you soon at the piggies
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
More information about the Python-Dev
mailing list