Antoine Pitrou <[EMAIL PROTECTED]> added the comment:

Le dimanche 29 juin 2008 à 17:43 +0000, Martin v. Löwis a écrit :
> For long, it's much more tricky, as no C type can be used to store the
> intermediate result. So instead, PyLong_FromString already allocates a
> sufficiently-sized long object (based on the number of digits of the
> input string), and then fills that object.
> 
> Depending on what precisely the complaint of this report is about, one
> solution could be to check after the conversion whether the result has
> only one digit, and if so, whether it is a small integer, and if so,
> convert it to a long, discard it, and use PyLong_FromLong.
> 
> If the complaint is that it unnecessarily allocates memory in the first
> place, I don't think anything should be done about that - the allocation
> is really necessary.

The bug entry is just for pointing out a missed optimization
opportunity. The first mentioned solution would already be an
improvement, although of course it would even be better to skip the
intermediary allocation altogether.

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3236>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to