SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
10.
Say, thousands of people using your
code everyday and if you save 1
second to run it, this means you
could save over 4 days of time
human race wasted per a year.
11.
See How Computer Works
and How Fast Computer
and it s peripherals
22.
1Hz
L1 Cache Acces
L2 Cache Access
L3 Cache Access
RAM Access
SSD I/O
HDD I/O
Internet: Tokyo to SF
Run IPython (0.6s)
Reboot (5m)
3s
9s
43s
6m
2-6 days
1-12 months
12 years
63 years
32,000 years!!
23.
Disassemble Python Code To
CPython Bytecode
To Support Analysis
dis module
https://docs.python.org/3/library/dis.html
https://github.com/python/cpython/blob/master/Include/opcode.h
24.
line # of source
op addr / instruction annotations
param
32.
line_profiler
• can profile line-by-line basis
• Uses a decorator to mark the
chosen function (@profile)
• introduces greater overhead
https://github.com/rkern/line_profiler
33.
profiling
• Interactive Python profiler which
inspired from Unity3D Profiler
• Keep the call stack.
• Live Profiling
• Only Support Linux
https://github.com/what-studio/profiling
36.
fibona
Korean Fried Chicken Served as one
chicken. (not pieces)
And it’s quite complex to determine
how many chicken would enough for
N people.
37.
fibona
The problem can be solved easily
using fibonacci number.
1 1 2 3 5 8 13 21 34 …
For Nth fibonacci number of people,
N-1 th fibonacci number of chicken
would be perfect.
38.
fibona
Awesome Idea! but how do you get
enough chicken if number of the
people is not an fibonacci number?
39.
fibona
Apply Zeckendorf’s theorem,
which is about the representation of
integers as sum of Fibonacci number
54.
Hypothesis #2
Can we improve is_fibonacci() not to
use fib() at all?
55.
n is a Fibonacci number if and only if 5n*n+4 or
5n*n-4 is a square
Gessel s Formula
http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibFormula.html