Code Monkey home page Code Monkey logo

fast-python's Introduction

Fast Python

Source code for Fast Python (2020) by Chris Conlan

Paperback available for purchase on Amazon.


Code profiles

The following code profiles can be run as stand-alone scripts. They may or may not depend on explanation provided in the accompanying book.

Running them is simple ...

cd fast-python/src
python cumulative_sum.py

Profiling

All the profiles use a simple profiling module in src/utils/profiler.py. It produces tables and charts like the following.

np_fast_cusum
    n   = 56234132 values
    t   = 201.806 ms
    n/t = 278653.8114 values per ms

np_fast_cusum
    n   = 100000000 values
    t   = 350.611 ms
    n/t = 285216.7553 values per ms

...

                function   n_values  t_milliseconds  values_per_ms
0             slow_cusum          1           0.012        85.0196
1             slow_cusum          3           0.005       640.7530
...
14            slow_cusum       5623        1298.218         4.3313
15            slow_cusum      10000        4140.327         2.4153
...
30   slow_cusum_expanded       5623        1878.419         2.9935
31   slow_cusum_expanded      10000        5767.316         1.7339
...
62     python_fast_cusum   56234132        5727.162      9818.8478
63     python_fast_cusum  100000000       10939.993      9140.7733
...
94     pandas_fast_cusum   56234132         442.652    127039.2437
95     pandas_fast_cusum  100000000         780.461    128129.3962
...
126     numba_fast_cusum   56234132         139.602    402816.3295
127     numba_fast_cusum  100000000         236.445    422930.9936
...
158        np_fast_cusum   56234132         201.806    278653.8114
159        np_fast_cusum  100000000         350.611    285216.7553

I use the profiler frequently in my own work. It allows me to analyze the relationship between computational complexity and raw execution time pretty easily.


Dependencies

I have included a dependencies.txt, but you should be fine with a blank Python 3 environment followed by ...

pip install numpy pandas numba joblib matplotlib pillow

fast-python's People

Contributors

chrisconlan avatar rhabraken avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.