Martin v. Löwis <[EMAIL PROTECTED]> added the comment: For the old int type, implementing this was trivial, as the conversion converted into a C long, then called PyInt_FromLong.
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. In any case, I think PyLong_FromString should also call long_normalize before returning the result. ---------- nosy: +loewis _______________________________________ 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