#how does vim implements `:py` python sessions?

20 messages · Page 1 of 1 (latest)

storm cobalt
#

hi, rn i write my own text editor & copy features from other text editors,
one feature which i'm trying to copy is vim :py python sessions
try:

:py a=21
:py print(a)

it outputs:

21

if it keeps track of variables, it must have python running somewhere in a backgroud.

first i thought it forks python process, but running:

pstree <vim pid>

reveals that it does not have any children processes

vim───{vim}

so how do it do that?

rotund lotusBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

dire dune
#

I think Python is just being called as needed as functions.

dire dune
#

Like it's not its own process, vim is just using it as a library.

#

The library has functions to set up a context and interpret lines of code.

storm cobalt
#
nm -A `which vim`
nm: /usr/bin/vim: no symbols
#

does nm needs executable to be compiled with debug symbols for it to work?

dire dune
#

Don't use Linux much so no idea.

storm cobalt
#

oh

dire dune
#

On my Windows setup Python is dynamically linked though.

storm cobalt
#

not on mine

#
ldd `which vim`
    linux-vdso.so.1 (0x000079fdfad6c000)
    libm.so.6 => /usr/lib/libm.so.6 (0x000079fdfa711000)
    libncursesw.so.6 => /usr/lib/libncursesw.so.6 (0x000079fdfaccc000)
    libacl.so.1 => /usr/lib/libacl.so.1 (0x000079fdfacc3000)
    libgpm.so.2 => /usr/lib/libgpm.so.2 (0x000079fdfacbb000)
    libc.so.6 => /usr/lib/libc.so.6 (0x000079fdfa520000)
    /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x000079fdfad6e000)
#

yea its statically linked, you're right

#

and it even converts to using dynamic python lib when you're on windows in the soruce code so everything checks out

rotund lotusBOT
#

@storm cobalt Has your question been resolved? If so, type !solved :)

storm cobalt
#

!solved