[pydotorg-www] One question in PythonSpeed PerformanceTips

三张 532000663 at qq.com
Tue Nov 21 01:45:48 EST 2017


Hello,

    PerformanceTips is detailed and useful for python developer, where I have improved myself a lot. In the learning, I found a question in “Use xrange instead of range” section about the example code below:
def xrange(start, stop=None, step=1):
    if stop is None:
        stop = start
        start = 0
    else:
        stop = int(stop)
    start = int(start)
    step = int(step)

    while start < stop:
        yield start
        start += step
    The example code run type conversion only under the case that the stop variable is not None, so, if I run code ”xrange('5’)", the code can not work.
    
    I have no authorization to edit this page, and by the way, wiki.python.org is too hard to register. it will help more people who have interesting in python if you spend time to check the code and correct it.

    Best wish.
    

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pydotorg-www/attachments/20171121/c76ffb66/attachment.html>


More information about the pydotorg-www mailing list