only 9% faster than pure python? That is very surprising as the C
implementation I had of this blew the python implementation out of the
water and it is essentially the same as what you're doing in this code.
What size arrays are you testing on?


On Sat, Apr 12, 2014 at 11:26 AM, Jorge Cañardo Alastuey <
notifications@github.com> wrote:

> In skbio/maths/_subsample.pyx:
>
> > +
> > +    >>> sub = subsample([1, 0, 1, 2, 2, 3, 0, 1], 5, replace=True)
> > +    >>> sub.sum()
> > +    5
> > +    >>> sub.shape
> > +    (8,)
> > +
> > +    """
> > +    cdef cnp.ndarray[cnp.int64_t, ndim=1] result, permuted, unpacked
> > +    cdef cnp.int64_t cnt, unpacked_idx, i, j
> > +
> > +    if n < 0:
> > +        raise ValueError("n cannot be negative.")
> > +
> > +
> > +    counts = np.asarray(counts)
>
> Very good catch! It does remain an object, so assigning to a new typed
> array gives a 15% speedup (~9x faster than pure Python now).
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/biocore/scikit-bio/pull/262/files#r11560687>
> .
>