decimal threading cost?

Robin Becker robin at reportlab.com
Fri Jan 22 07:35:02 EST 2010


On 22/01/2010 11:50, Mark Dickinson wrote:
> On Jan 22, 11:11 am, Robin Becker<ro... at reportlab.com>  wrote:
>> Does using the decimal module incur a penalty because it imports threading or do
>> I have to actually start a thread?
>
> There is at least one threading-related performance penalty that
> doesn't involve the user actually starting a thread: any arithmetic
> operation without an explicitly specified context (e.g., as invoked by
> one of the standard arithmetic operators) has to make a call to
> threading.local() to look up the current (thread-local) context.
>
> I don't know offhand whether this penalty is significant for the
> Python version of decimal, though it definitely *is* significant for
> decimal-in-C rewrite that's in the works:  it would be interesting to
> do some timings against a thread-unaware version of decimal.py.
>
> --
> Mark

I guess I was more worried that the import might start the per thread 
instruction count check even though I'm in a single thread process.
-- 
Robin Becker




More information about the Python-list mailing list