import random
source_list = [random.randrange(1000) for _ in range(10_000_000)]
def one(source):
counter = 0
for i in source:
if i < 20:
counter += 1
return counter
%time print(one(source_list))
200291
CPU times: user 468 ms, sys: 31.9 ms, total: 500 ms
Wall time: 508 ms
def two(source):
counter = 0
for i in filter(lambda x: x < 20, source):
counter += 1
return counter
%time print(two(source_list))
200291
CPU times: user 1.04 s, sys: 7.29 ms, total: 1.04 s
Wall time: 1.05 s
def three(source):
list_filter = lambda x: x < 20
counter = 0
for i in filter(list_filter, source):
counter += 1
return counter
%time print(three(source_list))
200291
CPU times: user 1.1 s, sys: 11.5 ms, total: 1.12 s
Wall time: 1.12 s
def four(source):
return sum((1 for i in source if i < 20))
%time print(four(source_list))
200291
CPU times: user 422 ms, sys: 9.24 ms, total: 431 ms
Wall time: 437 ms
www.unixuser.org/~euske/python/pdfminer/programmin...
LTFigure
Represents an area used by PDF Form objects. PDF Forms can be used to present figures or pictures by embedding yet another PDF document within a page. Note that LTFigure objects can appear recursively.
two_dict = {4:{'key':'test_1', 'key_2':'test_21'}, 5:{'key':'test_11', 'key_2':'test_22'}}
result = [two_dict[x] for x in two_dict if two_dict[x]['key'] == 'test_1']
result
[{'key': 'test_1', 'key_2': 'test_21'}]