skorokithakis / pastery.vim

A Vim plugin for the sweetest pastebin in the world, pastery.net.
https://www.pastery.net/
9 stars 5 forks source link

Use autoloading for Python code. #3

Closed meribold closed 4 years ago

meribold commented 4 years ago

This considerably cuts down load time. These are the values I previously got on a ThinkPad X220 running Arch Linux with Vim and Neovim, respectively:

102.437  044.233  044.233: sourcing /home/meribold/.vim/pack/meribold/opt/pastery.vim/plugin/pastery.vim
244.743  084.827  084.459: sourcing /home/meribold/.config/nvim/pack/meribold/opt/pastery.vim/plugin/pastery.vim

Now I get these values:

058.102  000.068  000.068: sourcing /home/meribold/.vim/pack/meribold/opt/pastery.vim/plugin/pastery.vim
156.885  001.137  000.816: sourcing /home/meribold/.config/nvim/pack/meribold/opt/pastery.vim/plugin/pastery.vim

Instead of about 40 or 80 milliseconds (depending on whether Vim or Neovim is used), pastery.vim now loads in a millisecond or less.

Note: Vim seems to use Python 2 and Neovim Python 3 on my system.

See https://learnvimscriptthehardway.stevelosh.com/chapters/53.html and :h autoload.

skorokithakis commented 4 years ago

This is some advanced vim-fu, I will review, thanks!

skorokithakis commented 4 years ago

Thank you!

meribold commented 4 years ago

Thank you for Pastery, Stavros :)