Skip to content

Instantly share code, notes, and snippets.

@angad
Created September 11, 2014 08:14
Show Gist options
  • Save angad/93b63502730bfb1af253 to your computer and use it in GitHub Desktop.
Save angad/93b63502730bfb1af253 to your computer and use it in GitHub Desktop.
user_dict.py
from array import array
users = {}
for user in range(50 * 1000 * 1000):
if user % 1000000 == 0:
print user
s = array('h')
for day in range(28):
s.append(day)
users[user] = s
print "done"
import time
time.sleep(10000)
from array import array
n = 1 * 1000 * 1000
def set_append_unique():
s = set()
for i in range(n):
s.add(i)
return s
def array_append_unique():
a = array('l')
for i in range(n):
a.append(i)
return a
def set_append_non_unique():
s = set_append_unique()
for i in range(n):
s.add(i)
return s
def array_append_non_unique():
a = array_append_unique()
s = set(a)
a = array('l')
for i in range(n):
s.add(i)
for x in s: a.append(x)
return a
def main():
#print len(set_append_unique())
#print len(array_append_unique())
print len(set_append_non_unique())
#print len(array_append_non_unique())
if __name__ == '__main__':
import profile
profile.run("main()")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment