python - numpy: boolean indexing and memory usage -


consider following numpy code:

a[start:end] = b[mask] 

here:

  • a , b 2d arrays same number of columns;
  • start , end scalars;
  • mask 1d boolean array;
  • (end - start) == sum(mask).

in principle, above operation can carried out using o(1) temporary storage, copying elements of b directly a.

is happens in practice, or numpy construct temporary array b[mask]? if latter, there way avoid rewriting statement?

using boolean arrays index fancy indexing, numpy needs make copy. write cython extension deal it, if getting memory problems.


Comments

Popular posts from this blog

haskell - Using filter on an item in a list? -

c# - When does PreApplicationStartMethod actually get triggered to run? -

tomcat6 - Exception when stopping container for a with Spring + Quartz + Tomcat web application -