npfastsortcpp


Namenpfastsortcpp JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/npfastsortcpp
SummarySorts int/float 4x faster than numpy by using parallel_sort from C++ (Windows only)
upload_time2023-02-01 22:16:53
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords c++ numpy sort
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Sorts int/float 4x faster than numpy by using parallel_sort from C++





## the bigger the array, the bigger the difference





### pip install npfastsortcpp 



It is basically a self-compiling Windows version of [https://stackoverflow.com/a/28663374/15096247](https://stackoverflow.com/a/28663374/15096247)





## Make sure you use the right MSVC C++ x64/x86 build tools (Link at the end of the description)





```python

# import the module:

from npfastsortcpp import parallelsort







# optional (if you want to check if the fast

# version is used) 

# If the fast version can not be imported, 

# you will see a warning when you call parallelsort

from npfastsortcpp import npfastsortconfig

npfastsortconfig.enablewarning=True

```







```

The first time you import the module, you will see this:

______________________________

Compiling ... 

If you get an error, download:

 https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&channel=Release&version=VS2022&source=VSLandingPage&passive=false&cid=2030

and install: MSVC ..... C++ x64/x86 build tools

______________________________

Compiling C:/Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp/npparallelsortcpp.pyx because it changed.

[1/1] Cythonizing C:/Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp/npparallelsortcpp.pyx

running build_ext

building 'npparallelsortcpp' extension

"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\Gamer\anaconda3\envs\stopjogo\include -IC:\Users\Gamer\anaconda3\envs\stopjogo\Include "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /EHsc /TpC:/Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp/npparallelsortcpp.cpp /Fobuild\temp.win-amd64-cpython-39\Release\Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp/npparallelsortcpp.obj

npparallelsortcpp.cpp

C:/Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp/npparallelsortcpp.cpp(2746): warning C4244: '=': conversion from 'long' to 'char', possible loss of data

"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\HostX86\x64\link.exe" /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Users\Gamer\anaconda3\envs\stopjogo\libs /LIBPATH:C:\Users\Gamer\anaconda3\envs\stopjogo /LIBPATH:C:\Users\Gamer\anaconda3\envs\stopjogo\PCbuild\amd64 "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22621.0\\um\x64" /EXPORT:PyInit_npparallelsortcpp build\temp.win-amd64-cpython-39\Release\Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp/npparallelsortcpp.obj /OUT:C:\Users\Gamer\anaconda3\envs\stopjogo\lib\site-packages\npfastsortcpp\npparallelsortcpp.cp39-win_amd64.pyd /IMPLIB:build\temp.win-amd64-cpython-39\Release\Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp\npparallelsortcpp.cp39-win_amd64.lib

   Creating library build\temp.win-amd64-cpython-39\Release\Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp\npparallelsortcpp.cp39-win_amd64.lib and object build\temp.win-amd64-cpython-39\Release\Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp\npparallelsortcpp.cp39-win_amd64.exp

Generating code

Finished generating code

```







### **If you get an error, download:**



[https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&channel=Release&version=VS2022&source=VSLandingPage&passive=false&cid=2030](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&channel=Release&version=VS2022&source=VSLandingPage&passive=false&cid=2030)





### **and install:**



MSVC ..... C++ x64/x86 build tools





### Let's compare numpy and npfastsortcpp





```python



from npfastsortcpp import parallelsort

from time import perf_counter

import numpy as np

arr=np.random.randint(1, 15000000 + 1,size=15000000)

#arr=np.random.randn(5000000)

arr2 = arr.copy()

start=perf_counter()

parallelsort(arr) # Sorting is in place! The function returns None!

print(f'npfastsortcpp: {perf_counter() - start}')

start=perf_counter()

np.sort(arr2)

print(f'numpy: {perf_counter() - start}')

npfastsortcpp: 0.27110049999998864

numpy: 0.9681288999999964







arr=np.random.randn(5000000)

arr2 = arr.copy()

start=perf_counter()

parallelsort(arr) # Sorting is in place! The function returns None!

print(f'npfastsortcpp: {perf_counter() - start}')

start=perf_counter()

np.sort(arr2)

print(f'numpy: {perf_counter() - start}')

npfastsortcpp: 0.11203969999999686

numpy: 0.35269389999999134

```




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/npfastsortcpp",
    "name": "npfastsortcpp",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "c++,numpy,sort",
    "author": "Johannes Fischer",
    "author_email": "<aulasparticularesdealemaosp@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/1a/cf/78a461fdb4f957fff8a4592473db6b45a2a3252905ff57b847b5bebe9f64/npfastsortcpp-0.10.tar.gz",
    "platform": null,
    "description": "\n# Sorts int/float 4x faster than numpy by using parallel_sort from C++\n\n\n\n\n\n## the bigger the array, the bigger the difference\n\n\n\n\n\n### pip install npfastsortcpp \n\n\n\nIt is basically a self-compiling Windows version of [https://stackoverflow.com/a/28663374/15096247](https://stackoverflow.com/a/28663374/15096247)\n\n\n\n\n\n## Make sure you use the right MSVC C++ x64/x86 build tools (Link at the end of the description)\n\n\n\n\n\n```python\n\n# import the module:\n\nfrom npfastsortcpp import parallelsort\n\n\n\n\n\n\n\n# optional (if you want to check if the fast\n\n# version is used) \n\n# If the fast version can not be imported, \n\n# you will see a warning when you call parallelsort\n\nfrom npfastsortcpp import npfastsortconfig\n\nnpfastsortconfig.enablewarning=True\n\n```\n\n\n\n\n\n\n\n```\n\nThe first time you import the module, you will see this:\n\n______________________________\n\nCompiling ... \n\nIf you get an error, download:\n\n https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&channel=Release&version=VS2022&source=VSLandingPage&passive=false&cid=2030\n\nand install: MSVC ..... C++ x64/x86 build tools\n\n______________________________\n\nCompiling C:/Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp/npparallelsortcpp.pyx because it changed.\n\n[1/1] Cythonizing C:/Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp/npparallelsortcpp.pyx\n\nrunning build_ext\n\nbuilding 'npparallelsortcpp' extension\n\n\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX86\\x64\\cl.exe\" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\\Users\\Gamer\\anaconda3\\envs\\stopjogo\\include -IC:\\Users\\Gamer\\anaconda3\\envs\\stopjogo\\Include \"-IC:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\include\" \"-IC:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\VS\\include\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.22621.0\\ucrt\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22621.0\\\\um\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22621.0\\\\shared\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22621.0\\\\winrt\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22621.0\\\\cppwinrt\" \"-IC:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\include\\um\" /EHsc /TpC:/Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp/npparallelsortcpp.cpp /Fobuild\\temp.win-amd64-cpython-39\\Release\\Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp/npparallelsortcpp.obj\n\nnpparallelsortcpp.cpp\n\nC:/Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp/npparallelsortcpp.cpp(2746): warning C4244: '=': conversion from 'long' to 'char', possible loss of data\n\n\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX86\\x64\\link.exe\" /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\\Users\\Gamer\\anaconda3\\envs\\stopjogo\\libs /LIBPATH:C:\\Users\\Gamer\\anaconda3\\envs\\stopjogo /LIBPATH:C:\\Users\\Gamer\\anaconda3\\envs\\stopjogo\\PCbuild\\amd64 \"/LIBPATH:C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\lib\\x64\" \"/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\lib\\um\\x64\" \"/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.22621.0\\ucrt\\x64\" \"/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\10\\\\lib\\10.0.22621.0\\\\um\\x64\" /EXPORT:PyInit_npparallelsortcpp build\\temp.win-amd64-cpython-39\\Release\\Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp/npparallelsortcpp.obj /OUT:C:\\Users\\Gamer\\anaconda3\\envs\\stopjogo\\lib\\site-packages\\npfastsortcpp\\npparallelsortcpp.cp39-win_amd64.pyd /IMPLIB:build\\temp.win-amd64-cpython-39\\Release\\Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp\\npparallelsortcpp.cp39-win_amd64.lib\n\n   Creating library build\\temp.win-amd64-cpython-39\\Release\\Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp\\npparallelsortcpp.cp39-win_amd64.lib and object build\\temp.win-amd64-cpython-39\\Release\\Users/Gamer/anaconda3/envs/stopjogo/lib/site-packages/npfastsortcpp\\npparallelsortcpp.cp39-win_amd64.exp\n\nGenerating code\n\nFinished generating code\n\n```\n\n\n\n\n\n\n\n### **If you get an error, download:**\n\n\n\n[https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&channel=Release&version=VS2022&source=VSLandingPage&passive=false&cid=2030](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&channel=Release&version=VS2022&source=VSLandingPage&passive=false&cid=2030)\n\n\n\n\n\n### **and install:**\n\n\n\nMSVC ..... C++ x64/x86 build tools\n\n\n\n\n\n### Let's compare numpy and npfastsortcpp\n\n\n\n\n\n```python\n\n\n\nfrom npfastsortcpp import parallelsort\n\nfrom time import perf_counter\n\nimport numpy as np\n\narr=np.random.randint(1, 15000000 + 1,size=15000000)\n\n#arr=np.random.randn(5000000)\n\narr2 = arr.copy()\n\nstart=perf_counter()\n\nparallelsort(arr) # Sorting is in place! The function returns None!\n\nprint(f'npfastsortcpp: {perf_counter() - start}')\n\nstart=perf_counter()\n\nnp.sort(arr2)\n\nprint(f'numpy: {perf_counter() - start}')\n\nnpfastsortcpp: 0.27110049999998864\n\nnumpy: 0.9681288999999964\n\n\n\n\n\n\n\narr=np.random.randn(5000000)\n\narr2 = arr.copy()\n\nstart=perf_counter()\n\nparallelsort(arr) # Sorting is in place! The function returns None!\n\nprint(f'npfastsortcpp: {perf_counter() - start}')\n\nstart=perf_counter()\n\nnp.sort(arr2)\n\nprint(f'numpy: {perf_counter() - start}')\n\nnpfastsortcpp: 0.11203969999999686\n\nnumpy: 0.35269389999999134\n\n```\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Sorts int/float 4x faster than numpy by using parallel_sort from C++ (Windows only)",
    "version": "0.10",
    "split_keywords": [
        "c++",
        "numpy",
        "sort"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "735c7298ea1f71743f503567fe7ac4ebbb7754457a1322b7141f28c50d1f1aa5",
                "md5": "f50230e252785e4640e9d5ccdb42e2d4",
                "sha256": "4cd08a10cbc839f920908450c3ea4efeffaa51c6d1d017876b1cbbde14d0c6f2"
            },
            "downloads": -1,
            "filename": "npfastsortcpp-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f50230e252785e4640e9d5ccdb42e2d4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7843,
            "upload_time": "2023-02-01T22:16:51",
            "upload_time_iso_8601": "2023-02-01T22:16:51.884429Z",
            "url": "https://files.pythonhosted.org/packages/73/5c/7298ea1f71743f503567fe7ac4ebbb7754457a1322b7141f28c50d1f1aa5/npfastsortcpp-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1acf78a461fdb4f957fff8a4592473db6b45a2a3252905ff57b847b5bebe9f64",
                "md5": "3ebcc4226f70a995a302bf8f9c0148b1",
                "sha256": "dcf876841c97fc5348915e455ea166f6a6a493010abea137e74ee34296bd52e5"
            },
            "downloads": -1,
            "filename": "npfastsortcpp-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "3ebcc4226f70a995a302bf8f9c0148b1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5954,
            "upload_time": "2023-02-01T22:16:53",
            "upload_time_iso_8601": "2023-02-01T22:16:53.228624Z",
            "url": "https://files.pythonhosted.org/packages/1a/cf/78a461fdb4f957fff8a4592473db6b45a2a3252905ff57b847b5bebe9f64/npfastsortcpp-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-01 22:16:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "hansalemaos",
    "github_project": "npfastsortcpp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "npfastsortcpp"
}
        
Elapsed time: 0.12150s