x = collections.defaultdict(list)

def secondwithout():
    x = collections.defaultdict(list)
print('first with import', timeit.timeit('first()',
    'from __main__ import first'))
print('second with import', timeit.timeit('second()',
    'from __main__ import second'))
print('first without import', timeit.timeit('firstwithout()',
    'from __main__ import firstwithout'))
print('second without import', timeit.timeit('secondwithout()',
    'from __main__ import secondwithout'))
Optimization of importing modules in Python