Skip to content

Conversation

@juliantaylor
Copy link
Contributor

PyArg_ParseTupleAndKeywords makes out about 20% of the runtime of small
reductions. Replace it with faster parsing using pre-interned python
strings. This improves performance by about 15% for reductions in the
order of 100 elements.
Error handling is done by calling PyArg_ParseTupleAndKeywords after the
fast parsing fails.

before:

d = np.arange(100)
%timeit np.sum(d)
100000 loops, best of 3: 4.79 µs per loop

after:

d = np.arange(100)
%timeit np.sum(d)
100000 loops, best of 3: 4.03 µs per loop

PyArg_ParseTupleAndKeywords makes out about 20% of the runtime of small
reductions. Replace it with faster parsing using pre-interned python
strings. This improves performance by about 15% for reductions in the
order of 100 elements.
Error handling is done by calling PyArg_ParseTupleAndKeywords after the
fast parsing fails.

before:

    d = np.arange(100)
    %timeit np.sum(d)
    100000 loops, best of 3: 4.79 µs per loop

after:

    d = np.arange(100)
    %timeit np.sum(d)
    100000 loops, best of 3: 4.03 µs per loop
@juliantaylor
Copy link
Contributor Author

this is still a prototype PR looking for comments on implementation.
something weird I saw is that add.reduce always gets 5 arguments (1 positional, 4 keywords) no matter how many the python code specifies, while minimum.reduce gets as many as the python code gives. Someone know of the top of their head why this happens? isn't both going through the same ufunc code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found <- find?

@juliantaylor
Copy link
Contributor Author

hm it might be possible to avoid adding a faster parser by changing some wrappers to not use keyword arguments, investigating.

@juliantaylor
Copy link
Contributor Author

sort of obsoleted by dropping the use of keyword arguments for the top level functions. I'll keep the branch around as the approach itself might be worthwhile for functions which use many keyword arguments. The array constructor could be a candidate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants