Python, VIM: namespace, scope, life of a python object stuck in a << HERE

Veek M vek.m1234 at gmail.com
Wed Nov 5 06:58:10 CET 2014


If i have two functions:

function! foo()
python3 << HERE
 import mylib
 pass
HERE

function! bar()
python3 << HERE
 import mylib
 pass
HERE

The src says:

 1. Python interpreter main program
 3. Implementation of the Vim module for Python

So, is the python interpreter embedded in vim AND additionally, are separate 
extensions to python provided (wrapper functions for the VIM API). Mixed 
bindings?

How many times is mylib compiled to bytecode and loaded? Does each vimscript 
function get its own mylib - can I instantiate something and expect it to be 
visible in the other function? I have a bunch of leader (\)-functions that 
share similar code and act on the same buffer so I wanted to know if I could 
reuse that data-structure. How many times is the interpreter loaded into 
memory: once obviously at vim runtime.




More information about the Python-list mailing list