creating temporary arrays

0 views
Skip to first unread message

kristofo...@gmail.com

unread,
Aug 18, 2016, 12:26:53 PM8/18/16
to Numba Public Discussion - Public
I have a short running function that is called many times. In this function I create some temporary arrays like,

    ix = np.empty((3,), dtype=np.int_)
    xd = np.empty((3,), dtype=point.dtype)  # points is a function argument with type numba.f4[:] or numba.f8[:]

Creating these temporary arrays makes my code run 3x slower than if I create them outside the function and pass them in as arguments; however, I don't like the notion of passing around a bunch of arrays to be used as a temporary workspace. Since the array size is known at compile time (as is the dtype of `point` thanks to jit compilation), I imagine the compiler should be able to create these arrays on the stack with little extra overhead, similar to the C code,

    int ix[3];
    float xd[3];

Is this currently achievable with Numba?

Stanley Seibert

unread,
Aug 19, 2016, 11:34:15 AM8/19/16
to Numba Public Discussion - Public
This is not currently possible, but it is a high priority for us to add.  We currently have someone working on it now.

--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users+unsubscribe@continuum.io.
To post to this group, send email to numba...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/afa9da2c-32df-48c5-993e-3abdcddae9ff%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

David Zwicker

unread,
Sep 25, 2018, 10:22:15 AM9/25/18
to Numba Public Discussion - Public
Is there any update on this issue? I ran into the same problem and the only reference about temporary arrays I could find was this post. What is currently the preferred way to associated some temporary memory with a numba compiled function?


On Friday, August 19, 2016 at 5:34:15 PM UTC+2, Stanley Seibert wrote:
This is not currently possible, but it is a high priority for us to add.  We currently have someone working on it now.
On Wed, Aug 17, 2016 at 10:27 PM, <kristofo...@gmail.com> wrote:
I have a short running function that is called many times. In this function I create some temporary arrays like,

    ix = np.empty((3,), dtype=np.int_)
    xd = np.empty((3,), dtype=point.dtype)  # points is a function argument with type numba.f4[:] or numba.f8[:]

Creating these temporary arrays makes my code run 3x slower than if I create them outside the function and pass them in as arguments; however, I don't like the notion of passing around a bunch of arrays to be used as a temporary workspace. Since the array size is known at compile time (as is the dtype of `point` thanks to jit compilation), I imagine the compiler should be able to create these arrays on the stack with little extra overhead, similar to the C code,

    int ix[3];
    float xd[3];

Is this currently achievable with Numba?

--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users...@continuum.io.
Reply all
Reply to author
Forward
0 new messages