Avoid conversion to NumPy Scalar
Avoid conversion to NumPy Scalar

After profiling I noticed that a bottleneck for NumPy scalar operations
occurs when trying to extract the underlying C value from a Python float
because it first converts the Python scalar into its matching NumPy
scalar (e.g. PyFloat -> float64) and then it extracts the C value from
the NumPy scalar.

For some types, it is a lot faster to just extract the value directly
from the Python scalar.

I only did for PyFloat in this modified code but the code is laid out
such that it can be easily extended to other types such as Integers. I
did not do them because I was unsure if there was a special scenario to
handle across OS and/or between 32 and 64 bit platforms. The ratio of
speed to do different operations are listed below (Old time / New time
with modifications). In other words, the bigger the number, the bigger
the speed up we get.

Tested in Python 2.6 Windows

RATIO  TEST
1.1  Array * Array
1.1  PyFloat * Array
1.1  Float64 * Array
1.0  PyFloat + Array
1.3  Float64 + Array
1.1  PyFloat * PyFloat
1.0  Float64 * Float64
4.0  PyFloat * Float64
2.9  PyFloat * vector1[1]
3.9  PyFloat + Float64
9.8  PyFloat < Float64
9.9  PyFloat < Float64
1.0  Create array from list
1.0  Assign PyFloat to all
1.0  Assign Float64 to all
4.2  Float64 * pyFloat * pyFloat * pyFloat * pyFloat
1.0  pyFloat * pyFloat * pyFloat * pyFloat * pyFloat
1.0  Float64 * Float64 * Float64 * Float64 * Float64
1.0  Float64 ** 2
1.0  pyFloat ** 2

jakirkham/numpy,Dapid/numpy,abalkin/numpy,maniteja123/numpy,groutr/numpy,pdebuyl/numpy,sonnyhu/numpy,MSeifert04/numpy,hainm/numpy,NextThought/pypy-numpy,gfyoung/numpy,hainm/numpy,mhvk/numpy,mhvk/numpy,maniteja123/numpy,ssanderson/numpy,empeeu/numpy,endolith/numpy,yiakwy/numpy,githubmlai/numpy,simongibbons/numpy,chatcannon/numpy,skymanaditya1/numpy,ChanderG/numpy,Dapid/numpy,cjermain/numpy,chatcannon/numpy,tdsmith/numpy,rmcgibbo/numpy,mortada/numpy,mindw/numpy,kirillzhuravlev/numpy,WillieMaddox/numpy,joferkington/numpy,jakirkham/numpy,gmcastil/numpy,WarrenWeckesser/numpy,immerrr/numpy,rherault-insa/numpy,embray/numpy,dato-code/numpy,Eric89GXL/numpy,jschueller/numpy,rudimeier/numpy,mathdd/numpy,trankmichael/numpy,ChristopherHogan/numpy,AustereCuriosity/numpy,kiwifb/numpy,abalkin/numpy,ahaldane/numpy,ChanderG/numpy,tdsmith/numpy,ekalosak/numpy,solarjoe/numpy,endolith/numpy,endolith/numpy,has2k1/numpy,immerrr/numpy,cowlicks/numpy,stuarteberg/numpy,WillieMaddox/numpy,felipebetancur/numpy,chatcannon/numpy,anntzer/numpy,mortada/numpy,mindw/numpy,BabeNovelty/numpy,CMartelLML/numpy,bringingheavendown/numpy,jankoslavic/numpy,bmorris3/numpy,jorisvandenbossche/numpy,mingwpy/numpy,brandon-rhodes/numpy,pyparallel/numpy,larsmans/numpy,pizzathief/numpy,sonnyhu/numpy,madphysicist/numpy,skwbc/numpy,mingwpy/numpy,stuarteberg/numpy,b-carter/numpy,sigma-random/numpy,tacaswell/numpy,bertrand-l/numpy,charris/numpy,sigma-random/numpy,mathdd/numpy,MaPePeR/numpy,rhythmsosad/numpy,CMartelLML/numpy,rgommers/numpy,SunghanKim/numpy,tynn/numpy,leifdenby/numpy,sinhrks/numpy,rudimeier/numpy,joferkington/numpy,jankoslavic/numpy,moreati/numpy,Srisai85/numpy,pbrod/numpy,BMJHayward/numpy,sonnyhu/numpy,GrimDerp/numpy,MSeifert04/numpy,tynn/numpy,andsor/numpy,ekalosak/numpy,trankmichael/numpy,rajathkumarmp/numpy,jankoslavic/numpy,MichaelAquilina/numpy,mwiebe/numpy,jschueller/numpy,Eric89GXL/numpy,dimasad/numpy,SunghanKim/numpy,musically-ut/numpy,utke1/numpy,bringingheavendown/numpy,brandon-rhodes/numpy,skwbc/numpy,sinhrks/numpy,BabeNovelty/numpy,MichaelAquilina/numpy,ajdawson/numpy,jorisvandenbossche/numpy,drasmuss/numpy,GrimDerp/numpy,Linkid/numpy,pbrod/numpy,numpy/numpy,joferkington/numpy,felipebetancur/numpy,tacaswell/numpy,rmcgibbo/numpy,dwillmer/numpy,ddasilva/numpy,cowlicks/numpy,ContinuumIO/numpy,jakirkham/numpy,anntzer/numpy,felipebetancur/numpy,ViralLeadership/numpy,ekalosak/numpy,grlee77/numpy,gfyoung/numpy,seberg/numpy,mattip/numpy,numpy/numpy,Yusa95/numpy,pyparallel/numpy,ahaldane/numpy,naritta/numpy,utke1/numpy,BMJHayward/numpy,shoyer/numpy,njase/numpy,MSeifert04/numpy,sigma-random/numpy,rhythmsosad/numpy,dwillmer/numpy,SunghanKim/numpy,solarjoe/numpy,dwillmer/numpy,WarrenWeckesser/numpy,ahaldane/numpy,ogrisel/numpy,ajdawson/numpy,ChristopherHogan/numpy,kirillzhuravlev/numpy,larsmans/numpy,jonathanunderwood/numpy,naritta/numpy,dimasad/numpy,andsor/numpy,ogrisel/numpy,ChristopherHogan/numpy,jorisvandenbossche/numpy,Linkid/numpy,Linkid/numpy,ddasilva/numpy,Anwesh43/numpy,mingwpy/numpy,utke1/numpy,SiccarPoint/numpy,madphysicist/numpy,rgommers/numpy,ekalosak/numpy,nbeaver/numpy,ahaldane/numpy,seberg/numpy,madphysicist/numpy,bertrand-l/numpy,mattip/numpy,WillieMaddox/numpy,skwbc/numpy,skymanaditya1/numpy,b-carter/numpy,pizzathief/numpy,njase/numpy,cowlicks/numpy,Eric89GXL/numpy,sinhrks/numpy,rmcgibbo/numpy,cjermain/numpy,brandon-rhodes/numpy,naritta/numpy,mhvk/numpy,ahaldane/numpy,dato-code/numpy,ViralLeadership/numpy,madphysicist/numpy,drasmuss/numpy,dato-code/numpy,sinhrks/numpy,mattip/numpy,GaZ3ll3/numpy,stuarteberg/numpy,Yusa95/numpy,mwiebe/numpy,charris/numpy,GaZ3ll3/numpy,jonathanunderwood/numpy,jakirkham/numpy,KaelChen/numpy,numpy/numpy,simongibbons/numpy,rgommers/numpy,anntzer/numpy,embray/numpy,nbeaver/numpy,ssanderson/numpy,chiffa/numpy,SiccarPoint/numpy,Anwesh43/numpy,jschueller/numpy,ChanderG/numpy,GrimDerp/numpy,AustereCuriosity/numpy,behzadnouri/numpy,MaPePeR/numpy,BabeNovelty/numpy,joferkington/numpy,empeeu/numpy,mwiebe/numpy,hainm/numpy,githubmlai/numpy,njase/numpy,WarrenWeckesser/numpy,jschueller/numpy,MichaelAquilina/numpy,seberg/numpy,GrimDerp/numpy,leifdenby/numpy,ChristopherHogan/numpy,ogrisel/numpy,bertrand-l/numpy,gmcastil/numpy,b-carter/numpy,yiakwy/numpy,grlee77/numpy,grlee77/numpy,argriffing/numpy,SiccarPoint/numpy,drasmuss/numpy,jankoslavic/numpy,kirillzhuravlev/numpy,bringingheavendown/numpy,rudimeier/numpy,andsor/numpy,nguyentu1602/numpy,behzadnouri/numpy,groutr/numpy,nguyentu1602/numpy,pbrod/numpy,pbrod/numpy,skymanaditya1/numpy,mhvk/numpy,bmorris3/numpy,mathdd/numpy,numpy/numpy,rajathkumarmp/numpy,CMartelLML/numpy,rhythmsosad/numpy,Anwesh43/numpy,CMartelLML/numpy,MichaelAquilina/numpy,madphysicist/numpy,gmcastil/numpy,SunghanKim/numpy,moreati/numpy,rmcgibbo/numpy,mingwpy/numpy,KaelChen/numpy,kirillzhuravlev/numpy,charris/numpy,pdebuyl/numpy,ESSS/numpy,behzadnouri/numpy,yiakwy/numpy,Yusa95/numpy,KaelChen/numpy,jakirkham/numpy,Dapid/numpy,nguyentu1602/numpy,rherault-insa/numpy,pbrod/numpy,dimasad/numpy,chiffa/numpy,tdsmith/numpy,groutr/numpy,embray/numpy,WarrenWeckesser/numpy,has2k1/numpy,shoyer/numpy,rherault-insa/numpy,maniteja123/numpy,kiwifb/numpy,MaPePeR/numpy,dato-code/numpy,mortada/numpy,nguyentu1602/numpy,solarjoe/numpy,larsmans/numpy,dch312/numpy,moreati/numpy,seberg/numpy,ViralLeadership/numpy,hainm/numpy,ContinuumIO/numpy,BabeNovelty/numpy,pyparallel/numpy,Srisai85/numpy,has2k1/numpy,trankmichael/numpy,brandon-rhodes/numpy,ESSS/numpy,GaZ3ll3/numpy,rudimeier/numpy,ogrisel/numpy,yiakwy/numpy,shoyer/numpy,bmorris3/numpy,cjermain/numpy,dch312/numpy,BMJHayward/numpy,simongibbons/numpy,has2k1/numpy,jorisvandenbossche/numpy,ddasilva/numpy,sigma-random/numpy,mindw/numpy,empeeu/numpy,simongibbons/numpy,ogrisel/numpy,githubmlai/numpy,argriffing/numpy,Srisai85/numpy,endolith/numpy,musically-ut/numpy,grlee77/numpy,felipebetancur/numpy,MSeifert04/numpy,bmorris3/numpy,ESSS/numpy,trankmichael/numpy,skymanaditya1/numpy,embray/numpy,WarrenWeckesser/numpy,NextThought/pypy-numpy,MaPePeR/numpy,pdebuyl/numpy,pizzathief/numpy,cjermain/numpy,tynn/numpy,stuarteberg/numpy,argriffing/numpy,charris/numpy,tacaswell/numpy,immerrr/numpy,Yusa95/numpy,grlee77/numpy,chiffa/numpy,Eric89GXL/numpy,Anwesh43/numpy,githubmlai/numpy,ajdawson/numpy,ssanderson/numpy,BMJHayward/numpy,rajathkumarmp/numpy,pdebuyl/numpy,nbeaver/numpy,rgommers/numpy,MSeifert04/numpy,gfyoung/numpy,KaelChen/numpy,sonnyhu/numpy,pizzathief/numpy,musically-ut/numpy,mhvk/numpy,shoyer/numpy,embray/numpy,AustereCuriosity/numpy,jorisvandenbossche/numpy,jonathanunderwood/numpy,naritta/numpy,anntzer/numpy,SiccarPoint/numpy,andsor/numpy,dwillmer/numpy,Linkid/numpy,abalkin/numpy,rajathkumarmp/numpy,larsmans/numpy,empeeu/numpy,immerrr/numpy,dch312/numpy,NextThought/pypy-numpy,ChanderG/numpy,shoyer/numpy,musically-ut/numpy,NextThought/pypy-numpy,ContinuumIO/numpy,mindw/numpy,simongibbons/numpy,dch312/numpy,leifdenby/numpy,dimasad/numpy,cowlicks/numpy,GaZ3ll3/numpy,ajdawson/numpy,mathdd/numpy,kiwifb/numpy,Srisai85/numpy,mattip/numpy,rhythmsosad/numpy,mortada/numpy,pizzathief/numpy,tdsmith/numpy