Re: [Python-Dev] an unimportant question, ...

2009-03-23 Thread Guido van Rossum
This is all over now, but I do think that the change from char to int
was made for alignment reasons. I don't know, but I could certainly
imagine that aligned memcpy calls are faster. I can't explain why I
still put the 3-byte savings comment in SVN -- perhaps I was in a
hurry.

On Sun, Mar 22, 2009 at 12:38 PM, Christian Tismer  wrote:
> On 3/22/09 8:01 PM, "Martin v. Löwis" wrote:
>>>
>>> Now, the internals are very clear to me. What I don't understand
>>> is where the three saved bytes should be.
>>
>> If you look at the various patches in
>>
>> http://bugs.python.org/issue576101
>>
>> then there is a three-byte saving in all versions from 1 to 6.
>> Consequentially, the API was changed in those versions (but only
>> starting from version 5, i.e. the first version created by Guido).
>>
>> For some reason, the saving was then removed from the patch that
>> got actually committed (#7). I guess the comment just stayed.
>
> Yes, funny, actually. At least, I don't find any comment why
> the char was turned into an int, after all.
> Are char pointers not on a word boundary problematic on some
> platforms?
>
> Or was it maybe to just keep the string layout on many
> common platforms compatible, in order to save rebuilding
> so many windows extension modules?
>
> If the latter is true and the only reason, I vote for reclaiming
> the three bytes. Maybe it saves a tree or two. Maybe it hurts
> very little if done for Python 3000.
>
> In any case, use the version that saves the most energy. :-)
>
> not kidding - ciao -- chris
>
> --
> Christian Tismer             :^)   
> tismerysoft GmbH             :     Have a break! Take a ride on Python's
> Johannes-Niemeyer-Weg 9A     :    *Starship* http://starship.python.net/
> 14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
> work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
> PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
>      whom do you want to sponsor today?   http://www.stackless.com/
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/guido%40python.org
>



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] an unimportant question, ...

2009-03-22 Thread Antoine Pitrou
Christian Tismer  stackless.com> writes:
> 
> Or was it maybe to just keep the string layout on many
> common platforms compatible, in order to save rebuilding
> so many windows extension modules?
> 
> If the latter is true and the only reason, I vote for reclaiming
> the three bytes. Maybe it saves a tree or two. Maybe it hurts
> very little if done for Python 3000.
> 
> In any case, use the version that saves the most energy. 

Well, if you want to make the str type in py3k smaller, there is a more massive
saving to be done by making it a PyVarObject, rather than allocating the storage
separately.

A patch has existed for that for a long time now, it probably needs updating if
anyone is interested:
http://bugs.python.org/issue1943



___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] an unimportant question, ...

2009-03-22 Thread Thomas Wouters
On Sun, Mar 22, 2009 at 20:38, Christian Tismer wrote:

> On 3/22/09 8:01 PM, "Martin v. Löwis" wrote:
>
>> Now, the internals are very clear to me. What I don't understand
>>> is where the three saved bytes should be.
>>>
>>
>> If you look at the various patches in
>>
>> http://bugs.python.org/issue576101
>>
>> then there is a three-byte saving in all versions from 1 to 6.
>> Consequentially, the API was changed in those versions (but only
>> starting from version 5, i.e. the first version created by Guido).
>>
>> For some reason, the saving was then removed from the patch that
>> got actually committed (#7). I guess the comment just stayed.
>>
>
> Yes, funny, actually. At least, I don't find any comment why
> the char was turned into an int, after all.
> Are char pointers not on a word boundary problematic on some
> platforms?
>
> Or was it maybe to just keep the string layout on many
> common platforms compatible, in order to save rebuilding
> so many windows extension modules?
>
> If the latter is true and the only reason, I vote for reclaiming
> the three bytes. Maybe it saves a tree or two. Maybe it hurts
> very little if done for Python 3000.
>
> In any case, use the version that saves the most energy. :-)
>
> not kidding - ciao -- chris


Actually, we should use the version that breaks the ABI the least. The
change you're referring to actually (comparatively silently!) broke the ABI
for 64-bit Python builds (at least, on LP64 and LLP64 systems, which is most
of them.)  You can normally relatively safely use an extension module built
for Python 2.2 in Python 2.4, but not so for 64-bit builds. Let's try to
keep the ABI compatible, and at least make it an error (not a warning) to
load a truly incompatible ABI version.

-- 
Thomas Wouters 

Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] an unimportant question, ...

2009-03-22 Thread Christian Tismer

On 3/22/09 8:01 PM, "Martin v. Löwis" wrote:

Now, the internals are very clear to me. What I don't understand
is where the three saved bytes should be.


If you look at the various patches in

http://bugs.python.org/issue576101

then there is a three-byte saving in all versions from 1 to 6.
Consequentially, the API was changed in those versions (but only
starting from version 5, i.e. the first version created by Guido).

For some reason, the saving was then removed from the patch that
got actually committed (#7). I guess the comment just stayed.


Yes, funny, actually. At least, I don't find any comment why
the char was turned into an int, after all.
Are char pointers not on a word boundary problematic on some
platforms?

Or was it maybe to just keep the string layout on many
common platforms compatible, in order to save rebuilding
so many windows extension modules?

If the latter is true and the only reason, I vote for reclaiming
the three bytes. Maybe it saves a tree or two. Maybe it hurts
very little if done for Python 3000.

In any case, use the version that saves the most energy. :-)

not kidding - ciao -- chris

--
Christian Tismer :^)   
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
  whom do you want to sponsor today?   http://www.stackless.com/
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] an unimportant question, ...

2009-03-22 Thread Christian Tismer

On 3/22/09 8:01 PM, "Martin v. Löwis" wrote:

Now, the internals are very clear to me. What I don't understand
is where the three saved bytes should be.


If you look at the various patches in

http://bugs.python.org/issue576101

then there is a three-byte saving in all versions from 1 to 6.
Consequentially, the API was changed in those versions (but only
starting from version 5, i.e. the first version created by Guido).

For some reason, the saving was then removed from the patch that
got actually committed (#7). I guess the comment just stayed.


That's very impressive!
Thank you very much for the enlightment.
Whow!

cheers - chris
--
Christian Tismer :^)   
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
  whom do you want to sponsor today?   http://www.stackless.com/
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] an unimportant question, ...

2009-03-22 Thread Martin v. Löwis
> Now, the internals are very clear to me. What I don't understand
> is where the three saved bytes should be.

If you look at the various patches in

http://bugs.python.org/issue576101

then there is a three-byte saving in all versions from 1 to 6.
Consequentially, the API was changed in those versions (but only
starting from version 5, i.e. the first version created by Guido).

For some reason, the saving was then removed from the patch that
got actually committed (#7). I guess the comment just stayed.

Regards,
Martin
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] an unimportant question, ...

2009-03-22 Thread Michael Foord

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  GvR1012Changes 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


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] an unimportant question, ...

2009-03-22 Thread Christian Tismer

... but I'm curious.

Hi Guido,

while working on Psyco, I stumbled over a log entry in modsupport.h:



   19-Aug-2002  GvR 1012Changes 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 :-)

all the best -- chris


p.s.: won't make it to PyCon this time, see you soon at the piggies
--
Christian Tismer :^)   
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
  whom do you want to sponsor today?   http://www.stackless.com/
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com