Comparisons and sorting of a numeric class....

Chris Angelico rosuav at gmail.com
Tue Jan 13 14:02:20 EST 2015


On Wed, Jan 14, 2015 at 5:56 AM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Tue, Jan 13, 2015 at 4:20 AM, Chris Angelico <rosuav at gmail.com> wrote:
>> On Tue, Jan 13, 2015 at 10:00 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>>> The code above, though, shouldn't consume memory since it is a simple
>>> tail-recursive loop.
>>
>> Only if the interpreter can optimize it away. Bear in mind that it
>> doesn't _return_ the result of that expression, so it needs to take
>> whatever f() returns, discard it, and return None.
>
> And CPython doesn't even try to optimize tail recursion anyway.

I presumed that Marko's "shouldn't" was "CPython should be smarter than this".

ChrisA



More information about the Python-list mailing list