fgallina/python.el — pull request #75 by dandavison (2012-03-20 05:56:24+00:00)
Title: Cache defun positions for `python-nav-jump-to-defun`

A C-u prefix argument to `python-nav-jump-to-defun` forces a rescan of
the buffer.

I really like the `jump-to-defun` functionality but it is too slow on some of my files (completely locks up emacs for 30 seconds or so on a large django models.py file with lots of classes with many methods). What do you think of caching the results? I'll probably use this quite a bit over the next few days so it will get more testing -- just wanted to run the idea by you.

Fwiw I did a quick profiling run with ```elp-instrument-package``` on an intermediate-size file which gave the following results:

```sh
python-nav-jump-to-defun 1 9.712364 9.712364
python-nav-read-defun 1 9.712278 9.712278
python-nav-list-defun-positions 1 6.214155 6.214155
python-info-current-defun 143 6.1378770000 0.0429222167
python-beginning-of-defun-function 10439 5.8377570000 0.0005592256
python-nav-beginning-of-defun 10439 5.4720650000 0.0005241943
python-info-ppss-context 10868 4.9387089999 0.0004544266
python-util-forward-comment 143 0.1149409999 0.0008037832
```