-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
add numba example to enhancingperf.rst #10257
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
Conversation
jreback
commented
Jun 3, 2015
+1 ! With the latest numba, I think you can do the empty array allocation inside the jitted function, instead of passing it as an argument. I find this a bit easier to follow, but of course in this way it also works with older versions. |
|
||
Read more in the `cython docs <http://docs.cython.org/>`__. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you leave this link at the end of the cython section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
links already at the top of the section
@jorisvandenbossche for some reason, sphinx wouldn't render the decorators in the ipython blocks (e.g. the |
def compute_numba(df): | ||
result = np.empty(len(df), dtype='float64') | ||
apply_integrate_f_numba(df['a'].values,df['b'].values,df['N'].values,result) | ||
return Series(result,index=df.index,name='result') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small remark: PEP8, spaces after comma's
@jorisvandenbossche I put the allocation back. I think its ok. In the next version of numba, this will just be 'faster' (e.g. its all done in nopython mode). But seems to work ok. |
|
||
@numba.jit | ||
def apply_integrate_f_numba(col_a, col_b, col_N): | ||
result = np.empty(len(df), dtype='float64') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
df
is not defined here, can use n
probably
b6f5e6a
to
412e375
Compare
Note that the version of Numba that will be able to do the memory allocation in nopython mode will be coming out today. |
@seibert hmm, this is seeming to execute in nopython mode already though? (I guess except for the allocation, which prob doesn't matter in perf as its a single event), right? |
It does not execute in nopython mode with current stable version of numba, but because of the loop lifting of the main part of the function, it does not make that much of a difference I think. @seibert yes, I was referring to that version, but forgot that it was only a beta release announcement that I saw |
Right, loop-lifting means that allocating memory in nopython mode is not as exciting as you might initially think. :) |
@jreback Could you replace the cython timings with a Generally this looks good to me |
add numba example to enhancingperf.rst
@shoyer updated to use all verbatims.. |