Skip to content

Commit 6628319

Browse files
committed
ENH: Avoid array copies
Avoid array copies if possible Add link time optimization for gcc builds
1 parent de3c5eb commit 6628319

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

randomstate/bounded_integers.pxi.in

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ cdef object _rand_{{nptype}}(object low, object high, object size, aug_state *st
7777
cdef np.broadcast it
7878
cdef int buf_rem = 0
7979

80-
81-
low = np.asarray(low)
82-
high = np.asarray(high)
80+
low = np.array(low, copy=False)
81+
high = np.array(high, copy=False)
8382
low_ndim = np.PyArray_NDIM(<np.ndarray>low)
8483
high_ndim = np.PyArray_NDIM(<np.ndarray>high)
8584
if ((low_ndim == 0 or (low_ndim==1 and low.size==1 and size is not None)) and
@@ -200,8 +199,8 @@ cdef object _rand_{{nptype}}(object low, object high, object size, aug_state *st
200199
cdef {{nptype}}_t low_v, high_v
201200
cdef uint64_t rng, last_rng, val, mask, off, out_val
202201

203-
low = np.asarray(low)
204-
high = np.asarray(high)
202+
low = np.array(low, copy=False)
203+
high = np.array(high, copy=False)
205204
low_ndim = np.PyArray_NDIM(<np.ndarray>low)
206205
high_ndim = np.PyArray_NDIM(<np.ndarray>high)
207206
if ((low_ndim == 0 or (low_ndim==1 and low.size==1 and size is not None)) and

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
compile_rngs = rngs[:]
3838

3939
extra_defs = [('_CRT_SECURE_NO_WARNINGS', '1')] if os.name == 'nt' else []
40-
extra_link_args = ['/LTCG', '/OPT:REF', 'Advapi32.lib', 'Kernel32.lib'] if os.name == 'nt' else []
41-
base_extra_compile_args = [] if os.name == 'nt' else ['-std=c99']
40+
extra_link_args = ['/LTCG', '/OPT:REF', 'Advapi32.lib', 'Kernel32.lib'] if os.name == 'nt' else ['-flto']
41+
base_extra_compile_args = [] if os.name == 'nt' else ['-std=c99','-flto']
4242
if USE_SSE2:
4343
if os.name == 'nt':
4444
base_extra_compile_args += ['/wd4146', '/GL']

0 commit comments

Comments
 (0)