On Wed, Apr 15, 2009 at 11:25 AM, Stefan Behnel <[email protected]> wrote:
> Hi,
>
> thanks for sharing that.
>
> Brent Pedersen wrote:
>> assuming i haven't done anything stupid
>
> No, nothing stupid, but something that can reduce the comparability of the
> timings. You are creating a 1000000 item list on each benchmark, using a
> call to range() in some cases and a list comprehension in others.
>
> It's usually better to move initialisations out of the timings, e.g. by
> creating a large range() object once and re-using it. That reduces the
> impact of unrelated operations on the absolute numbers.
>

ah, i see, updated that. fixing that makes the python constructor look
even slower.
now it assumes that creating a list comprehension without assgning to
a variable is
the same as calling a function that returns an array--also without assigning.

here are the new timings:

PY_NEW on Cython class: 1.137
__init__ on Python class: 28.468
__init__ on Python class with slots: 9.936
batch PY_NEW total: 0.821 , interval only: 0.363
batch __init__ on Cython class total 0.975 , interval_only: 0.524
__init__ on Cython class 1.154

so for this case using PY_NEW macro actual doesnt improve speed that
much over a cdef'ed class.
especially if using a "batch" method is applicable (as it is for my use-case).

i didnt realize slots would affect on object creation time that much
-- in this case it's 3x faster with slots!
(and then another 6-10x with a cdef'ed class)

here's my updated gist:
http://gist.github.com/95916


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

Reply via email to