You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
448 B
Python
24 lines
448 B
Python
#!/usr/bin/python
|
|
|
|
from memory_profiler import profile
|
|
import numpy as np
|
|
|
|
# From
|
|
# http://stackoverflow.com/questions/27464039/why-the-performance-difference-between-numpy-zeros-and-numpy-zeros-like
|
|
|
|
N = (1000, 1000)
|
|
M = (slice(None, 500, None), slice(500, None, None))
|
|
|
|
@profile
|
|
def test1(N, M):
|
|
print(N, M)
|
|
x = np.zeros(N)
|
|
y = np.empty(N)
|
|
z = np.zeros_like(x)
|
|
x[M] = 1
|
|
y[M] = 1
|
|
z[M] = 1
|
|
return x,y,z
|
|
|
|
test1(N, M)
|