Use inline heuristic function. No significant difference.
Stop.
Premature optimization is the root of all evil.
profile
Stop.
Premature optimization is the root of all evil.
profile
Spoiler :
Code:
>>> cProfile.run('h(1,1,70,70)')
heapq with heuristic
False
Time 2.40100002289
Visited 3435
179835 function calls (179510 primitive calls) in 2.404 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 2.404 2.404 <string>:1(<module>)
13 0.000 0.000 0.003 0.000 <string>:493(write)
13 0.000 0.000 0.000 0.000 brine.py:107(_dump_str)
78/13 0.000 0.000 0.001 0.000 brine.py:138(_dump_tuple)
156/13 0.000 0.000 0.001 0.000 brine.py:161(_dump)
13 0.000 0.000 0.002 0.000 brine.py:273(dump)
65/13 0.000 0.000 0.000 0.000 brine.py:286(dumpable)
91/52 0.000 0.000 0.000 0.000 brine.py:291(<genexpr>)
65 0.000 0.000 0.000 0.000 brine.py:90(_dump_int)
13 0.000 0.000 0.000 0.000 channel.py:42(send)
13 0.000 0.000 0.002 0.000 protocol.py:149(_send)
13 0.000 0.000 0.003 0.000 protocol.py:156(_send_request)
13 0.000 0.000 0.000 0.000 protocol.py:170(_box)
13 0.000 0.000 0.003 0.000 protocol.py:350(_async_request)
1 0.000 0.000 0.001 0.001 r.py:18(show)
22342 0.080 0.000 0.134 0.000 r.py:21(dist)
30915 0.059 0.000 0.087 0.000 r.py:39(isValid)
1 2.144 2.144 2.401 2.401 r.py:66(h)
1 0.000 0.000 2.404 2.404 r.py:7(g)
13 0.000 0.000 0.000 0.000 stream.py:112(write)
3435 0.010 0.000 0.010 0.000 {_heapq.heappop}
3434 0.005 0.000 0.005 0.000 {_heapq.heappush}
44684 0.032 0.000 0.032 0.000 {abs}
39/13 0.000 0.000 0.000 0.000 {all}
3580 0.003 0.000 0.003 0.000 {len}
22342 0.022 0.000 0.022 0.000 {max}
13 0.000 0.000 0.000 0.000 {method 'acquire' of 'thread.lock' objects}
3591 0.003 0.000 0.003 0.000 {method 'append' of 'list' objects}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
31071 0.028 0.000 0.028 0.000 {method 'get' of 'dict' objects}
13 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects}
31 0.000 0.000 0.000 0.000 {method 'pack' of 'Struct' objects}
13 0.000 0.000 0.000 0.000 {method 'release' of 'thread.lock' objects}
13 0.000 0.000 0.000 0.000 {method 'send' of '_socket.socket' objects}
13740 0.016 0.000 0.016 0.000 {range}
2 0.000 0.000 0.000 0.000 {time.time}
Spoiler :
Code:
>>> cProfile.run('f3(1,1,70,70)')
zahlen
False
Time 0.881999969482
Visited 3435
66134 function calls (65809 primitive calls) in 0.883 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.883 0.883 <string>:1(<module>)
13 0.000 0.000 0.003 0.000 <string>:493(write)
13 0.000 0.000 0.000 0.000 brine.py:107(_dump_str)
78/13 0.000 0.000 0.002 0.000 brine.py:138(_dump_tuple)
156/13 0.001 0.000 0.002 0.000 brine.py:161(_dump)
13 0.000 0.000 0.002 0.000 brine.py:273(dump)
65/13 0.000 0.000 0.000 0.000 brine.py:286(dumpable)
91/52 0.000 0.000 0.000 0.000 brine.py:291(<genexpr>)
65 0.000 0.000 0.000 0.000 brine.py:90(_dump_int)
13 0.000 0.000 0.000 0.000 channel.py:42(send)
13 0.000 0.000 0.002 0.000 protocol.py:149(_send)
13 0.000 0.000 0.003 0.000 protocol.py:156(_send_request)
13 0.000 0.000 0.001 0.000 protocol.py:170(_box)
13 0.000 0.000 0.003 0.000 protocol.py:350(_async_request)
1 0.800 0.800 0.881 0.881 r.py:164(f3)
1 0.000 0.000 0.001 0.001 r.py:18(show)
27480 0.049 0.000 0.072 0.000 r.py:39(isValid)
1 0.000 0.000 0.883 0.883 r.py:7(g)
13 0.000 0.000 0.000 0.000 stream.py:112(write)
39/13 0.000 0.000 0.000 0.000 {all}
157 0.000 0.000 0.000 0.000 {len}
13 0.000 0.000 0.000 0.000 {method 'acquire' of 'thread.lock' objects}
10147 0.008 0.000 0.008 0.000 {method 'append' of 'list' objects}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
27636 0.023 0.000 0.023 0.000 {method 'get' of 'dict' objects}
13 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects}
44 0.000 0.000 0.000 0.000 {method 'pack' of 'Struct' objects}
13 0.000 0.000 0.000 0.000 {method 'release' of 'thread.lock' objects}
13 0.000 0.000 0.000 0.000 {method 'send' of '_socket.socket' objects}
2 0.000 0.000 0.000 0.000 {time.time}