Mohamed Lrhazi wrote:
> Would it make sense to use Cython merely to avoid writing C? That is,
> am I missing something in thinking that I could do that?
>
> Assume I wrote a foo.pyx, which uses an external C lib. foo calls
> functions on the C lib and defines callbacks the latter lib will be
> calling. I then compile the foo.pyx into foo.so, then write a shell
> script that runs: python -c 'import foo'
>
> Could someone explain, in OS level terms, what would be happening when
> this shell script is running? what would the Python VM be doing? would
> it be idle all the time, while the Cython generated code is all that's
> running? is there a way to avoid that by compiling the foo.pyx
> directly into native executable?

Well, look at the Python executable as two parts:
 a) A library with lots of objects, interfaces etc. for strings, numbers,
classes etc
 b) An interpreter for Python code

The interpreter part would hardly be run at all -- it would interpret
"import foo" and then wait on that. But that is just some code sitting in
memory and having it around doesn't hurt.

You need part a) for Cython programs, and that answers your last question
("no").

All in all, what happens is that the interpreter part of Python does some
things, then does a call into the C code Cython generates which doesn't
return until your application closes.

Bottom line: Unless the memory usage or startup time is a problem, don't
worry about this, just do it :-)

(Hmm.. perhaps someone could comment on any other threads that are running
or reference cycle collection -- but I wouldn't expect it to be a
problem.)

Dag Sverre

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to