neovim/python-client — pull request #19 by tarruda (2014-08-09 20:33:45+00:00)
Title: More optimizations to get close to upstream vim performance

After these changes I finally got acceptable performance with upstream YouCompleteMe.

The cProfile report showed that:

- python logging has a significant impact even with the module disabled at debug level. Unlike with C log macros, python log statements are not removed at compile time, so the small call overhead build up in "hotspots"
- The current implementation of the `Buffer.__iter__` method turned out to be the biggest culprit to the bad performance YCM had with Neovim. It happened because when gathering buffer data, YCM iterates through the buffer which means one msgpack-rpc roundtrip per line(a buffer with 20k lines meant 20k api calls)

To fix these issues:

- I will now use a script to comment all the log statements before pushing to pypi. The same script can be used to uncomment the statements if logging is required by an user. The script is courtesy of [this article](http://dound.com/2010/02/python-logging-performance/)
- The `Buffer.__iter__` method now evaluates the whole buffer before yielding lines

When running the YCM benchmark described at #17, I got the following results with the `time` command utility:

vim + ycm:

```
$ time vim
vim 0.72s user 0.12s system 39% cpu 2.129 total
```

nvim + ycm:

```
$ time nvim
nvim 0.92s user 0.14s system 48% cpu 2.177 total
```