Multithreaded Performance/Embedding

Aahz Maruch aahz at netcom.com
Thu May 4 09:40:44 EDT 2000


In article <39110799.2415927D at sunesis-pharma.com>,
Warren L. DeLano <warren at sunesis-pharma.com> wrote:
>
>I am writing a multithreaded molecular modeling program in C and Python
>and I am finding a substantial difference in execution speed of the C
>components (3-4X) depending on whether I embed python (fast) or import
>my code in as a module (slow).  Is this normal?
>
>Since the C-code is running as a separate thread with Python threads
>unblocked, I don't see why there should be any difference in performance
>-- but the difference is huge! If the python interpreter is the master
>thread (vs being embedded), it seems to add a 50-75% overhead onto my
>C-code execution speed.

Let's make sure we understand the problem first.  Your C code spawns its
own threads?  And you're saying that if you do a straight Python call
into your C code, your C code runs much slower?  You aren't using Python
threads at all?  If the answer to any of these questions is "no", try
converting them to "yes".
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"Laws that restrict speech are an abomination for a simple reason.
They're like a poison gas; they seem to be a good weapon to vanquish
your enemy, but the wind has a way of shifting."  -- Ira Glasser



More information about the Python-list mailing list