In the following snippet, the loop in the global namespace takes twice as long
as the loop in the function namespace.  Why?

    limit = 50000000

    def f1():
        counter = 0
        while counter < limit:
            counter += 1
    time1 = time.time()
    f1()
    print(time.time() - time1)
    print('number of locals: ', len(locals()))

    time1 = time.time()
    counter = 0
    while counter < limit:
        counter += 1
    print(time.time() - time1)
    print('number of locals: ', len(locals()))

--
Yorick

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to