How Vim9 Boosts Script Performance Up to 10× – A Deep Dive
Vim9, an experimental branch of the Vim editor, introduces a new function definition model that dramatically speeds up Vim script execution, achieving performance comparable to Lua and surpassing Python, while addressing top‑requested features and preparing changes for integration into Vim.
Vim’s creator Bram Moolenaar originally built Vim as an enhanced version of Vi, and now he is developing an experimental branch called Vim9 to improve Vim’s scripting speed.
Vim9 aims to make Vim script execute faster, addressing top‑requested features such as popup windows and text properties. Bram notes that the current way of calling functions with dictionaries for arguments and local variables is a performance bottleneck.
If the execution speed could be doubled, Vim’s overall performance would improve noticeably because each function call incurs high overhead.
Functions will accept arguments only by name, not via a: dictionary or a:000 list.
Local variables will no longer be accessible through the l: dictionary.
Other speed‑affecting details, such as exception‑handling, will be refined.
A proof‑of‑concept shows Vim taking five seconds for a simple loop, while Vim9 completes it in 0.07 seconds, matching Lua and surpassing Python.
let sum = 0
for i in range(1, 2999999)
let sum += i
endforIn a more realistic script, Vim9 runs in 0.19 seconds compared with Vim’s 0.85 seconds.
let totallen = 0
for i in range(1, 100000)
call setline(i, ' ' .. getline(i))
let totallen += len(getline(i))
endforFurther details and the implementation are available in the Vim9 GitHub repository; validated changes will eventually be merged into Vim.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
