[IronPython] Performance issue when calling a function with **kw

Curt Hagenlocher curt at hagenlocher.org
Mon Aug 4 17:18:00 CEST 2008


There is a bit of extra code that's run when there are keyword arguments,
but I don't think it should make this kind of difference.  Please file a bug
report in CodePlex at http://www.codeplex.com/IronPython/WorkItem/List.aspx.

On Sun, Aug 3, 2008 at 3:31 AM, Asaf Kleinbort <asaf at itstructures.com>wrote:

>  Hi all,
>
> I am new to this list, so I'll first introduce myself.
>
> I am working at *IT Structures* (www.itstructures.com)  in Israel. Our
> service Is written in C#, but most of the backend implementation is written
> in IronPython.
>
> While doing performance analysis of our application, I came across the
> following interesting bug (?):
>
>
>
> Calling a function with **kw takes about 10 times more time than calling a
> function with a simple dictionary.  The difference exists also in cpython
> but there the differences is hardly noticed.
>
>
>
> Here is a code snippet to clarify:
>
>>
> *def func_kw(kw):*
>
> *    return sum(kw.itervalues())*
>
> * *
>
> *def func(**kw):*
>
> *    return sum(kw.itervalues())*
>
> *    *
>
> *def measure(n):*
>
> *    dct = {'1':2,'2':2,'3':2,'4':2,'5':2,'6':2}*
>
> *    start = time.clock()*
>
> *    for i in xrange(n):*
>
> *        func_kw(dct)*
>
> *    duration_without = time.clock()-start*
>
> *    start = time.clock()*
>
> *    for i in xrange(n):*
>
> *        func(**dct)*
>
> *    duration_with = time.clock()-start*
>
> *    return (duration_without,duration_with)*
>
> *…*
>
>
>
> Running measure(10**6) 10 times in a loop and calculating the mean we get
> the following results (in seconds):
>
>
>
> *In IronPython:*
>
> *WITH **KW: mean=5.56493157650, stddev=0.0649572929575.*
>
> *WITHOUT: mean=0.86113346808, stddev=0.0142532589459.*
>
>
>
> *In Python:*
>
> * WITH **KW: mean=1.70669562131, stddev=0.0230977726849.*
>
> * WITHOUT: mean=0.782945815118, stddev=0.00572116553432. *
>
> * *
>
> *(*IronPython version: IronPython 1.1.1 (1.1.1) on .NET 2.0.50727.1433
>
> Python version: Python 2.5.1)
>
>
>
> Does anyone know if this is going to improve in version 2.0?
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080804/fe7bc185/attachment.html>


More information about the Ironpython-users mailing list