<s>
NumPy	B-Application
(	O
pronounced	O
(	O
)	O
or	O
sometimes	O
(	O
)	O
)	O
is	O
a	O
library	B-Library
for	O
the	O
Python	B-Language
programming	I-Language
language	I-Language
,	O
adding	O
support	O
for	O
large	O
,	O
multi-dimensional	O
arrays	B-Data_Structure
and	O
matrices	B-Architecture
,	O
along	O
with	O
a	O
large	O
collection	O
of	O
high-level	B-Language
mathematical	O
functions	O
to	O
operate	O
on	O
these	O
arrays	B-Data_Structure
.	O
</s>
<s>
The	O
predecessor	O
of	O
NumPy	B-Application
,	O
Numeric	O
,	O
was	O
originally	O
created	O
by	O
Jim	O
Hugunin	O
with	O
contributions	O
from	O
several	O
other	O
developers	O
.	O
</s>
<s>
In	O
2005	O
,	O
Travis	O
Oliphant	O
created	O
NumPy	B-Application
by	O
incorporating	O
features	O
of	O
the	O
competing	O
Numarray	O
into	O
Numeric	O
,	O
with	O
extensive	O
modifications	O
.	O
</s>
<s>
NumPy	B-Application
is	O
open-source	B-Application
software	I-Application
and	O
has	O
many	O
contributors	O
.	O
</s>
<s>
NumPy	B-Application
is	O
a	O
NumFOCUS	O
fiscally	O
sponsored	O
project	O
.	O
</s>
<s>
The	O
Python	B-Language
programming	I-Language
language	I-Language
was	O
not	O
originally	O
designed	O
for	O
numerical	B-General_Concept
computing	I-General_Concept
,	O
but	O
attracted	O
the	O
attention	O
of	O
the	O
scientific	O
and	O
engineering	O
community	O
early	O
on	O
.	O
</s>
<s>
In	O
1995	O
the	O
special	O
interest	O
group	O
(	O
SIG	O
)	O
matrix-sig	O
was	O
founded	O
with	O
the	O
aim	O
of	O
defining	O
an	O
array	B-Application
computing	I-Application
package	O
;	O
among	O
its	O
members	O
was	O
Python	B-Language
designer	O
and	O
maintainer	O
Guido	O
van	O
Rossum	O
,	O
who	O
extended	O
Python	B-Language
's	I-Language
syntax	I-Language
(	O
in	O
particular	O
the	O
indexing	O
syntax	O
)	O
to	O
make	O
array	B-Application
computing	I-Application
easier	O
.	O
</s>
<s>
An	O
implementation	O
of	O
a	O
matrix	O
package	O
was	O
completed	O
by	O
Jim	O
Fulton	O
,	O
then	O
generalized	O
by	O
Jim	O
Hugunin	O
and	O
called	O
Numeric	O
(	O
also	O
variously	O
known	O
as	O
the	O
"	O
Numerical	B-Application
Python	I-Application
extensions	O
"	O
or	O
"	O
NumPy	B-Application
"	O
)	O
.	O
</s>
<s>
Hugunin	O
,	O
a	O
graduate	O
student	O
at	O
the	O
Massachusetts	O
Institute	O
of	O
Technology	O
(	O
MIT	O
)	O
,	O
joined	O
the	O
Corporation	O
for	O
National	O
Research	O
Initiatives	O
(	O
CNRI	O
)	O
in	O
1997	O
to	O
work	O
on	O
JPython	B-Language
,	O
leaving	O
Paul	O
Dubois	O
of	O
Lawrence	O
Livermore	O
National	O
Laboratory	O
(	O
LLNL	O
)	O
to	O
take	O
over	O
as	O
maintainer	O
.	O
</s>
<s>
Numarray	O
had	O
faster	O
operations	O
for	O
large	O
arrays	B-Data_Structure
,	O
but	O
was	O
slower	O
than	O
Numeric	O
on	O
small	O
ones	O
,	O
so	O
for	O
a	O
time	O
both	O
packages	O
were	O
used	O
in	O
parallel	O
for	O
different	O
use	O
cases	O
.	O
</s>
<s>
There	O
was	O
a	O
desire	O
to	O
get	O
Numeric	O
into	O
the	O
Python	B-Language
standard	O
library	B-Library
,	O
but	O
Guido	O
van	O
Rossum	O
decided	O
that	O
the	O
code	O
was	O
not	O
maintainable	O
in	O
its	O
state	O
then	O
.	O
</s>
<s>
In	O
early	O
2005	O
,	O
NumPy	B-Application
developer	O
Travis	O
Oliphant	O
wanted	O
to	O
unify	O
the	O
community	O
around	O
a	O
single	O
array	O
package	O
and	O
ported	O
Numarray	O
's	O
features	O
to	O
Numeric	O
,	O
releasing	O
the	O
result	O
as	O
NumPy	B-Application
1.0	O
in	O
2006	O
.	O
</s>
<s>
This	O
new	O
project	O
was	O
part	O
of	O
SciPy	B-Application
.	O
</s>
<s>
To	O
avoid	O
installing	O
the	O
large	O
SciPy	B-Application
package	O
just	O
to	O
get	O
an	O
array	O
object	O
,	O
this	O
new	O
package	O
was	O
separated	O
and	O
called	O
NumPy	B-Application
.	O
</s>
<s>
Support	O
for	O
Python	B-Language
3	O
was	O
added	O
in	O
2011	O
with	O
NumPy	B-Application
version	O
1.5.0	O
.	O
</s>
<s>
In	O
2011	O
,	O
PyPy	B-Language
started	O
development	O
on	O
an	O
implementation	O
of	O
the	O
NumPy	B-Application
API	B-General_Concept
for	O
PyPy	B-Language
.	O
</s>
<s>
It	O
is	O
not	O
yet	O
fully	O
compatible	O
with	O
NumPy	B-Application
.	O
</s>
<s>
NumPy	B-Application
targets	O
the	O
CPython	B-Language
reference	O
implementation	O
of	O
Python	B-Language
,	O
which	O
is	O
a	O
non-optimizing	O
bytecode	O
interpreter	B-Application
.	O
</s>
<s>
Mathematical	O
algorithms	O
written	O
for	O
this	O
version	O
of	O
Python	B-Language
often	O
run	O
much	O
slower	O
than	O
compiled	B-Language
equivalents	O
due	O
to	O
the	O
absence	O
of	O
compiler	B-Language
optimization	O
.	O
</s>
<s>
NumPy	B-Application
addresses	O
the	O
slowness	O
problem	O
partly	O
by	O
providing	O
multidimensional	O
arrays	B-Data_Structure
and	O
functions	O
and	O
operators	O
that	O
operate	O
efficiently	O
on	O
arrays	B-Data_Structure
;	O
using	O
these	O
requires	O
rewriting	O
some	O
code	O
,	O
mostly	O
inner	O
loops	O
,	O
using	O
NumPy	B-Application
.	O
</s>
<s>
Using	O
NumPy	B-Application
in	O
Python	B-Language
gives	O
functionality	O
comparable	O
to	O
MATLAB	B-Language
since	O
they	O
are	O
both	O
interpreted	O
,	O
and	O
they	O
both	O
allow	O
the	O
user	O
to	O
write	O
fast	O
programs	O
as	O
long	O
as	O
most	O
operations	O
work	O
on	O
arrays	B-Data_Structure
or	O
matrices	B-Architecture
instead	O
of	O
scalars	O
.	O
</s>
<s>
In	O
comparison	O
,	O
MATLAB	B-Language
boasts	O
a	O
large	O
number	O
of	O
additional	O
toolboxes	O
,	O
notably	O
Simulink	B-Application
,	O
whereas	O
NumPy	B-Application
is	O
intrinsically	O
integrated	O
with	O
Python	B-Language
,	O
a	O
more	O
modern	O
and	O
complete	O
programming	O
language	O
.	O
</s>
<s>
Moreover	O
,	O
complementary	O
Python	B-Language
packages	O
are	O
available	O
;	O
SciPy	B-Application
is	O
a	O
library	B-Library
that	O
adds	O
more	O
MATLAB-like	O
functionality	O
and	O
Matplotlib	B-Language
is	O
a	O
plotting	B-Application
package	O
that	O
provides	O
MATLAB-like	O
plotting	B-Application
functionality	O
.	O
</s>
<s>
Internally	O
,	O
both	O
MATLAB	B-Language
and	O
NumPy	B-Application
rely	O
on	O
BLAS	B-Application
and	O
LAPACK	B-Application
for	O
efficient	O
linear	B-Language
algebra	I-Language
computations	O
.	O
</s>
<s>
Python	B-Language
bindings	B-Application
of	O
the	O
widely	O
used	O
computer	B-Application
vision	I-Application
library	B-Library
OpenCV	B-Language
utilize	O
NumPy	B-Application
arrays	B-Data_Structure
to	O
store	O
and	O
operate	O
on	O
data	O
.	O
</s>
<s>
Since	O
images	O
with	O
multiple	O
channels	O
are	O
simply	O
represented	O
as	O
three-dimensional	O
arrays	B-Data_Structure
,	O
indexing	O
,	O
slicing	O
or	O
masking	O
with	O
other	O
arrays	B-Data_Structure
are	O
very	O
efficient	O
ways	O
to	O
access	O
specific	O
pixels	O
of	O
an	O
image	O
.	O
</s>
<s>
The	O
NumPy	B-Application
array	O
as	O
universal	O
data	O
structure	O
in	O
OpenCV	B-Language
for	O
images	O
,	O
extracted	O
feature	O
points	O
,	O
filter	B-Algorithm
kernels	I-Algorithm
and	O
many	O
more	O
vastly	O
simplifies	O
the	O
programming	O
workflow	O
and	O
debugging	B-Application
.	O
</s>
<s>
The	O
core	O
functionality	O
of	O
NumPy	B-Application
is	O
its	O
"	O
ndarray	O
"	O
,	O
for	O
n-dimensional	O
array	O
,	O
data	O
structure	O
.	O
</s>
<s>
These	O
arrays	B-Data_Structure
are	O
strided	B-Data_Structure
views	O
on	O
memory	B-General_Concept
.	O
</s>
<s>
In	O
contrast	O
to	O
Python	B-Language
's	O
built-in	O
list	O
data	O
structure	O
,	O
these	O
arrays	B-Data_Structure
are	O
homogeneously	O
typed	O
:	O
all	O
elements	O
of	O
a	O
single	O
array	O
must	O
be	O
of	O
the	O
same	O
type	O
.	O
</s>
<s>
Such	O
arrays	B-Data_Structure
can	O
also	O
be	O
views	O
into	O
memory	B-General_Concept
buffers	I-General_Concept
allocated	O
by	O
C/C	O
++	O
,	O
Python	B-Language
,	O
and	O
Fortran	B-Application
extensions	O
to	O
the	O
CPython	B-Language
interpreter	B-Application
without	O
the	O
need	O
to	O
copy	O
data	O
around	O
,	O
giving	O
a	O
degree	O
of	O
compatibility	O
with	O
existing	O
numerical	O
libraries	O
.	O
</s>
<s>
This	O
functionality	O
is	O
exploited	O
by	O
the	O
SciPy	B-Application
package	O
,	O
which	O
wraps	O
a	O
number	O
of	O
such	O
libraries	O
(	O
notably	O
BLAS	B-Application
and	O
LAPACK	B-Application
)	O
.	O
</s>
<s>
NumPy	B-Application
has	O
built-in	O
support	O
for	O
memory-mapped	B-General_Concept
ndarrays	O
.	O
</s>
<s>
Inserting	O
or	O
appending	O
entries	O
to	O
an	O
array	O
is	O
not	O
as	O
trivially	O
possible	O
as	O
it	O
is	O
with	O
Python	B-Language
's	O
lists	O
.	O
</s>
<s>
The	O
routine	O
to	O
extend	O
arrays	B-Data_Structure
actually	O
creates	O
new	O
arrays	B-Data_Structure
of	O
the	O
desired	O
shape	O
and	O
padding	O
values	O
,	O
copies	O
the	O
given	O
array	O
into	O
the	O
new	O
one	O
and	O
returns	O
it	O
.	O
</s>
<s>
NumPy	B-Application
's	O
operation	O
does	O
not	O
actually	O
link	O
the	O
two	O
arrays	B-Data_Structure
but	O
returns	O
a	O
new	O
one	O
,	O
filled	O
with	O
the	O
entries	O
from	O
both	O
given	O
arrays	B-Data_Structure
in	O
sequence	O
.	O
</s>
<s>
These	O
circumstances	O
originate	O
from	O
the	O
fact	O
that	O
NumPy	B-Application
's	O
arrays	B-Data_Structure
must	O
be	O
views	O
on	O
contiguous	O
memory	B-General_Concept
buffers	I-General_Concept
.	O
</s>
<s>
Algorithms	O
that	O
are	O
not	O
expressible	O
as	O
a	O
vectorized	O
operation	O
will	O
typically	O
run	O
slowly	O
because	O
they	O
must	O
be	O
implemented	O
in	O
"	O
pure	O
Python	B-Language
"	O
,	O
while	O
vectorization	O
may	O
increase	O
memory	B-General_Concept
complexity	O
of	O
some	O
operations	O
from	O
constant	O
to	O
linear	O
,	O
because	O
temporary	O
arrays	B-Data_Structure
must	O
be	O
created	O
that	O
are	O
as	O
large	O
as	O
the	O
inputs	O
.	O
</s>
<s>
Runtime	O
compilation	B-Language
of	O
numerical	O
code	O
has	O
been	O
implemented	O
by	O
several	O
groups	O
to	O
avoid	O
these	O
problems	O
;	O
open	O
source	O
solutions	O
that	O
interoperate	O
with	O
NumPy	B-Application
include	O
numexpr	O
and	O
Numba	B-Language
.	O
</s>
<s>
Cython	O
and	O
Pythran	O
are	O
static-compiling	O
alternatives	O
to	O
these	O
.	O
</s>
<s>
Many	O
modern	O
large-scale	B-Application
scientific	O
computing	O
applications	O
have	O
requirements	O
that	O
exceed	O
the	O
capabilities	O
of	O
the	O
NumPy	B-Application
arrays	B-Data_Structure
.	O
</s>
<s>
For	O
example	O
,	O
NumPy	B-Application
arrays	B-Data_Structure
are	O
usually	O
loaded	O
into	O
a	O
computer	O
's	O
memory	B-General_Concept
,	O
which	O
might	O
have	O
insufficient	O
capacity	O
for	O
the	O
analysis	O
of	O
large	O
datasets	B-General_Concept
.	O
</s>
<s>
Further	O
,	O
NumPy	B-Application
operations	O
are	O
executed	O
on	O
a	O
single	O
CPU	B-General_Concept
.	O
</s>
<s>
However	O
,	O
many	O
linear	B-Language
algebra	I-Language
operations	O
can	O
be	O
accelerated	O
by	O
executing	O
them	O
on	O
clusters	B-Architecture
of	O
CPUs	O
or	O
of	O
specialized	O
hardware	O
,	O
such	O
as	O
GPUs	B-Architecture
and	O
TPUs	B-Device
,	O
which	O
many	O
deep	B-Algorithm
learning	I-Algorithm
applications	O
rely	O
on	O
.	O
</s>
<s>
As	O
a	O
result	O
,	O
several	O
alternative	O
array	O
implementations	O
have	O
arisen	O
in	O
the	O
scientific	O
python	B-Language
ecosystem	O
over	O
the	O
recent	O
years	O
,	O
such	O
as	O
Dask	B-Operating_System
for	O
distributed	O
arrays	B-Data_Structure
and	O
TensorFlow	B-Language
or	O
for	O
computations	O
on	O
GPUs	B-Architecture
.	O
</s>
<s>
Because	O
of	O
its	O
popularity	O
,	O
these	O
often	O
implement	O
a	O
subset	O
of	O
NumPy	B-Application
's	O
API	B-General_Concept
or	O
mimic	O
it	O
,	O
so	O
that	O
users	O
can	O
change	O
their	O
array	O
implementation	O
with	O
minimal	O
changes	O
to	O
their	O
code	O
required	O
.	O
</s>
<s>
A	O
recently	O
introduced	O
library	B-Library
named	O
CuPy	B-Application
,	O
accelerated	O
by	O
Nvidia	O
's	O
CUDA	B-Architecture
framework	I-Architecture
,	O
has	O
also	O
shown	O
potential	O
for	O
faster	O
computing	O
,	O
being	O
a	O
'	O
drop-in	B-Architecture
replacement	I-Architecture
 '	O
of	O
NumPy	B-Application
.	O
</s>
<s>
Iterative	O
Python	B-Language
algorithm	O
and	O
vectorized	O
NumPy	B-Application
version	O
.	O
</s>
