Friday, March 15, 2013

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

The following is a simple test that compares the times it takes to
traverse a long list with FOR loop in Vimscript and in Python 2.x:

"-----BEGIN------------------------------
let start = reltime()
for i in range(1000000)
endfor
let time_vim = reltimestr(reltime(start))

let start = reltime()
python << EOF
for i in range(1000000): pass
EOF
let time_py = reltimestr(reltime(start))

echo 'Vim: ' time_vim
echo 'Python:' time_py
"-----END--------------------------------

The times I get (on an ancient computer):
Vim: 9.2 +- 0.2
Python: 0.26 +- 0.01

The exact times vary depending on how the test is done, but Vimscript
is invariably 30-45 times slower than Python. Why is there such a big
difference in performance?

--
--
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@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: