Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Avoiding conversion to NumPy Scalar. Implementation Copy-paste tag in conv_template.py #3556

Closed
wants to merge 4 commits into from

Conversation

arinkverma
Copy link
Contributor

This pr is based on same rationale and improvement suggested in @raulcota 's pr #2941. For some types, it is a lot faster to just extract the value directly from the Python scalar. It take care of main concerned of code duplication.

Implementation of copy and paste tag in cove_template.py

copy and paste tag

Example
Here is demo template

/**begin copy 
 *@hi@
 */
Hello! This is just a dummy line
 /**end copy**/

First I will write some useless line, then include code pasted to variable 
hi as /**paste @hi@**/

Output:

First I will write some useless line, then include code pasted to variable 
hi as Hello! This is just an dummy line

Usage

Here, we could avoid duplicating the whole function body just to add one specific check as per dtype.

Speed Up in Int

1.6 Array * Array
1.0 PyInt * Array
1.1 NyInt32 * Array
1.0 PyInt + Array
1.1 NyInt32 + Array
1.0 PyInt * PyInt
1.0 NyInt32 * NyInt32
2.2 PyInt * NyInt32
2.0 PyInt * Array[1]
2.2 PyInt + NyInt32
8.2 PyInt < NyInt32
1.0 NyInt32 * NyInt32 * NyInt32 * NyInt32 * NyInt32
2.2 NyInt32 ** 2.1828018936
0.9 PyInt ** 2

…ag in conv_template.py

For some types, it is a lot faster to just extract the value directly
from the Python scalar. So, in scalarmathmodule.src.c, avoided for PyFloat.
Fixed, wrongly seperated NPY_CDOUBLE instead of NPY_DOUBLE
Added avoiding of conversion of long, extracting its value
Fixed, extract the value directly from the Python3.3 scalar
@arinkverma arinkverma closed this Jul 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant