Here we test and check the performance of the array_arange implementation.
In [1]:
    
from __future__ import print_function
from functools import partial
from itertools import izip as zip, imap as map
from numpy import arange
import numpy as np
onesi = partial(np.ones, dtype=np.int32)
cumsumi = partial(np.cumsum, dtype=np.int32)
%matplotlib inline
    
In [2]:
    
def aarng(start, end):
    return np.hstack(map(arange, start, end))
    
In [3]:
    
def aarng_for_list(start, end):
    return np.hstack([arange(s, e) for s, e in zip(start, end)])
    
In [4]:
    
def aarng_for_gen(start, end):
    return np.hstack((arange(s, e) for s, e in zip(start, end)))
    
In [5]:
    
def aarng_concat(start, end):
    return np.concatenate(list(map(arange, start, end)))
    
In [6]:
    
def aarng_concat_list(start, end):
    return np.concatenate([arange(s, e) for s, e in zip(start, end)])
    
In [7]:
    
def aarng_concat_tuple(start, end):
    return np.concatenate(tuple(map(arange, start, end)))
    
In [19]:
    
def aarng_one(start, end):
    n = end - start
    arr = onesi(n.sum())
    # set pointers correct for cumsum
    ptr = cumsumi(n[:-1])
    arr[0] = start[0]
    arr[ptr] = start[1:]
    # Correct for previous values
    arr[ptr] -= start[:-1] + n[:-1] - 1
    return cumsumi(arr)
    
    
In [21]:
    
# Samples
N = 200000
start = np.random.randint(1000, size=N)
end = start + np.random.randint(10, size=N) + start
    
In [22]:
    
%timeit np.array((aarng(start, end)))
    
    
In [23]:
    
%timeit np.array(aarng_for_list(start, end))
    
    
In [24]:
    
%timeit np.array(aarng_for_gen(start, end))
    
    
In [25]:
    
%timeit np.array(aarng_concat(start, end))
    
    
In [26]:
    
%timeit np.array(aarng_concat_list(start, end))
    
    
In [27]:
    
%timeit np.array(aarng_concat_tuple(start, end))
    
    
In [28]:
    
%timeit np.array(aarng_one(start, end))
    
    
In [ ]: