Skip to content

Instantly share code, notes, and snippets.

View seantalts's full-sized avatar
🤣

seantalts

🤣
  • Columbia University
View GitHub Profile
>>> def greets(function):
... def greets_wrapper(*args, **kwargs):
... print "hi there, ", function
... return function(*args, **kwargs)
... return greets_wrapper
...
>>> @greets
... def add(num1, num2):
... return num1 + num2
...
feed_insights=# explain select count(distinct(user_id)) from interests where keywords in (select keywords from interests group by keywords having count(*) > 30);
QUERY PLAN
---------------------------------------------------------------------------------------------------
Aggregate (cost=2232807.48..2232807.49 rows=1 width=4)
-> Hash Join (cost=1780566.44..2221413.32 rows=4557663 width=4)
Hash Cond: (public.interests.keywords = public.interests.keywords)
-> Seq Scan on interests (cost=0.00..172441.36 rows=9188836 width=19)
-> Hash (cost=1778239.13..1778239.13 rows=133865 width=15)
-> GroupAggregate (cost=1706310.89..1776900.48 rows=133865 width=15)
Filter: (count(*) > 30)
import time
input = ['a', 'b', 'c', 'd', 'e', 'f']
iterations = 1000000
start = time.time()
for i in xrange(iterations):
s = dict([(x.lower(), i) for i, x in enumerate(input)])
end = time.time()
print "First thing took %s seconds" % (end - start)