Hi all,

I am investigating performance problems we have when running our code using
IPy2b5 (comparing to IPy 1.1.1).

Found two interesting issues:

1.       It seems that there is some bug in the 'sort' method

Running the following code:

 

from System import DateTime

def test():

    s = DateTime.Now

    for i in xrange(100000):

        a = [1,4,7,6,10,6]

        a.sort()

    return (DateTime.Now - s).TotalMilliseconds

            print test()

 

we get 3900% (!) degradation between IP1 and IPy2b5:  In IPy 1 the code runs
in 390ms and in IPy2b5: 15281ms

 

2.This is probably already known:  there is a major difference in
performance between an if/else block and a try/catch one:

        def func1(obj):

            try:

                return obj.prop

            except:

                return 0

       

                 def func2(obj):

            if hasattr(obj,'prop'):

                return obj.prop      

            else:

                return 0

 

        def test(s):

                     for i in xrange(100000):

                x = func1(set())

            return (DateTime.Now -s).TotalMilliseconds

        

        def test2(s):

            for i in xrange(10000):

                x = func2(set())

            return (DateTime.Now -s).TotalMilliseconds

                  

                 print test(DateTime.Now)

                 print test2(DateTime.Now)

                

Results for IPy1 and IPy2b5 are similar ~3000ms for 'test' and ~15ms for
'test2'. Using if/else is 200 times quicker. 

In Cpython it is only 2 times quicker.

 

We can bypass the second issue in our code, but the first one is harder to
ignore.

Are these issues already known? Any ideas? 

Thanks,

Asaf

 

 

_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to