[Python-3000] optimizing [x]range

"Martin v. Löwis" martin at v.loewis.de
Sun Jul 29 21:03:06 CEST 2007


>> Don't forget the *cost* in terms of code bloat. Plus, I asked for a
>> patch. Where is it? This is not Santa Claus's email address. You're
>> expected to contribute more than a wish.
> 
> first off all, that's not the politest way to put it, especially since i have
> submitted some patches before. second, i've already given a 3-line
> implementation in python. it would only take two minutes to convert
> it to C, save the unit tests. third, i'm busy over my head studying of
> my exams. forth, due to lack of public interest, i might as well
> withdraw this.

It's not that *you* were asked to contribute it. Guido just pointed
out that, without a patch, it won't get implemented. More so if
the patch is as trivial as you expect it to be. We *all* are
under time pressure - I am busy giving exams, for example.

So to your original question "why not optimize it?", there is
a very simple answer: there is no ready implementation available.

> besides, that's not the point. i'm only saying there's no reason that
> testing for containment in range objects (which are no longer lists),
> should be O(N), when it can easily be made O(1) in under 10 lines of C
> code.

Nothing is easy. Neal Norwitz was working on implementing xrange with
longs, and it took an entire week. The patch is still sitting on SF
somewhere.

Regards,
Martin


More information about the Python-3000 mailing list