This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients benjamin.peterson, loewis, pitrou
Date 2008-06-29.21:17:47
SpamBayes Score 0.00020070176
Marked as misclassified No
Message-id <1214774265.5934.3.camel@fsol>
In-reply-to <1214761411.95.0.0747772507398.issue3236@psf.upfronthosting.co.za>
Content
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.
History
Date User Action Args
2008-06-29 21:17:49pitrousetspambayes_score: 0.000200702 -> 0.00020070176
recipients: + pitrou, loewis, benjamin.peterson
2008-06-29 21:17:47pitroulinkissue3236 messages
2008-06-29 21:17:47pitroucreate