benchmark

Kris Kennaway kris at FreeBSD.org
Mon Aug 11 07:15:21 EDT 2008


Peter Otten wrote:
> M8R-n7vorv at mailinator.com wrote:
> 
>> On Aug 10, 10:10 pm, Kris Kennaway <k... at FreeBSD.org> wrote:
>>> jlist wrote:
>>>> I think what makes more sense is to compare the code one most
>>>> typically writes. In my case, I always use range() and never use psyco.
>>>> But I guess for most of my work with Python performance hasn't been
>>>> a issue. I haven't got to write any large systems with Python yet,
>>>> where performance starts to matter.
>>> Hopefully when you do you will improve your programming practices to not
>>> make poor choices - there are few excuses for not using xrange ;)
>>>
>>> Kris
>> And can you shed some light on how that relates with one of the zens
>> of python ?
>>
>> There should be one-- and preferably only one --obvious way to do it.
> 
> For the record, the impact of range() versus xrange() is negligable -- on my
> machine the xrange() variant even runs a tad slower. So it's not clear
> whether Kris actually knows what he's doing.

You are only thinking in terms of execution speed.  Now think about 
memory use.  Using iterators instead of constructing lists is something 
that needs to permeate your thinking about python or you will forever be 
writing code that wastes memory, sometimes to a large extent.

Kris



More information about the Python-list mailing list