Loading ...
Sorry, an error occurred while loading the content.

136782Re: Why is Vimscript/VimL much slower than Python when traversing long lists?

Expand Messages
  • Vlad Irnov
    Mar 18, 2013
    • 0 Attachment
      On 3/15/13, Marc Weber <marco-oweber@...> wrote:
      > VimL is known to be slow.

      Saying that VimL is slow is pointless without explaining exactly what is
      slow(er) and by how much. I am not aware of any actual comparisons of
      VimL performance vs other scripting languages. My own conclusion from
      very few crude tests is that VimL can be much slower than Python when
      dealing with long lists and strings, 20 to 100 times slower. In terms of
      actual execution times this only begins to matter with sizes >100000
      items. Using map(), filter(), etc. instead of "for" loop help somewhat.
      Not everything is slow, :g/pattern/... is fast.


      > If you know that you need speed use python or external tools.
      >
      > Why is it the way it is? I don't know.
      >
      > Eventually wait for better replies.
      >
      > I can recommend using a disnict .py file for writing python because then
      > you get all python support (syntax, completion, etc).
      >
      > If you want to learn how a .py file can be found by path have a look at
      > github.com/MarcWeber/scion-backend-vim
      >
      > let s:self=expand('<sfile>:h')

      I use Python a lot in my VOoM plugin. You are absolutely right that any
      substantial Python code should be in distinct .py files instead of
      inside .vim files.


      > You may also want to use a str quoting function like this:
      >
      > def vimQuote(s):
      > return '"%s"' % s.replace("\\","\\\\").replace('"', '\\"').replace("\n",
      > "\\n")
      >
      > because python's to str comes only close (maybe I should retry the to
      > json implementation and find out when whether it fails)
      >
      > Marc Weber

      I usually do
      "'%s'" % s.replace("'","''")

      Regards,
      Vlad

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Show all 8 messages in this topic