refactor and also look closer at performance
Comment From: paulproteus
This would be a fun task for anyone interested in learning more about using profilers in Python to make code run faster.
As I see it, there are two next steps here: - You need some sample code that uses DatetimeIndex.append (maybe try using it for a while, and write your own sample code that uses it) - You need to then run it in a Python profiler and understand the results.
Once you do that, you'll be able to know how much faster your modified version will be.
To run code in the Python profiler, the simplest way is to write a standalone Python script that contains the code you want to profile. Let's say it's in "script.py".
Instead of running:
python script.py
You run:
python -m cProfile -o stat.prof script.py
This loads the cProfile module, which enables profiling, and instructs cProfile to save statistics to stat.prof for later review. It then runs the code in script.py.
Then, you run this:
import pyprof2calltree pyprof2calltree.visualize('stat.prof')
And you get a text-based visualization of where the time is being spent. (You may need to 'pip install pyprof2calltree' or do something else to get pyprof2calltree on your system.)
I, personally, prefer a graphical visualization, so I do one more step: I install http://kcachegrind.sourceforge.net/html/Home.html and visualize stat.prof with that.
Comment From: jorisvandenbossche
If we have a specific benchmark where there is a performance bottleneck, we can re-open.