Created
December 5, 2016 06:31
-
-
Save msztolcman/4bac16a51114fdbf8863eacd3a4dc675 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from __future__ import print_function, unicode_literals | |
import os, os.path | |
import re | |
import sys | |
from pprint import pprint, pformat | |
import random | |
import time | |
size = 5000000 | |
st = time.time() | |
a = [random.randint(1, size) for _ in xrange(size)] | |
print("Random list init", time.time() - st) | |
st = time.time() | |
a = [i for i in range(size)] | |
print("Range list init", time.time() - st) | |
# Results for Py2: | |
# Random list init 8.04576992989 | |
# Range list init 0.624060153961 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment