Created
September 11, 2014 08:14
-
-
Save angad/93b63502730bfb1af253 to your computer and use it in GitHub Desktop.
user_dict.py
This file contains 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
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) |
This file contains 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
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