Python Code Snippets

  • Run benchmarks with timeit

https://docs.python.org/3/library/timeit.html

$ python3 -m timeit '"-".join(str(n) for n in range(100))'

>>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000)
  • Ruby’s binding.pry in Python
import code; code.interact(local=dict(globals(), **locals()))