{"id":25498171,"url":"https://github.com/hansalemaos/cinpy","last_synced_at":"2026-04-13T00:42:42.039Z","repository":{"id":65807895,"uuid":"600360029","full_name":"hansalemaos/cinpy","owner":"hansalemaos","description":"C/C++ in Python for Dummies","archived":false,"fork":false,"pushed_at":"2023-02-28T20:21:23.000Z","size":79,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-07T18:12:14.692Z","etag":null,"topics":["c","cpp","ctypes","numpy","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/cinpy/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hansalemaos.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-02-11T08:42:57.000Z","updated_at":"2023-02-11T09:00:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"53da573f-c9e8-4405-97cb-2371e7ef303a","html_url":"https://github.com/hansalemaos/cinpy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hansalemaos/cinpy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fcinpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fcinpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fcinpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fcinpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hansalemaos","download_url":"https://codeload.github.com/hansalemaos/cinpy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fcinpy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31735541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T22:19:12.206Z","status":"ssl_error","status_checked_at":"2026-04-12T22:18:33.088Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cpp","ctypes","numpy","python"],"created_at":"2025-02-19T02:21:23.867Z","updated_at":"2026-04-13T00:42:42.031Z","avatar_url":"https://github.com/hansalemaos.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# You have no clue about C/C++, but want to boost Python using C/C++ code? Try this!\n\n**cinpy** is made for people who never coded in C/C++, but want to use C/C++ functions/algorithms found somewhere on the internet (GitHub, Stack Overflow, ChatGPT …) in their Python code to speed things up.\n\n### This module is not for massive frameworks, only for small scripts/code snippets. It is very simple and straightforward to use.\n\n#### pip install cinpy\n\n## Please install:\n\nMSVC ..... C++ x64/x86 build tools from: \n[https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community\u0026channel=Release\u0026version=VS2022\u0026source=VSLandingPage\u0026passive=false\u0026cid=2030](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community\u0026channel=Release\u0026version=VS2022\u0026source=VSLandingPage\u0026passive=false\u0026cid=2030)\n\n#### Localize the following files (Version number might vary) and copy their path:\n\nvcvarsall_bat = r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\"\n\ncl_exe = r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\cl.exe\"\n\nlink_exe = r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\link.exe\"\n\n\n### Examples\n\n\n```python\n\n\nfrom cinpy import CreateCppDll\n\nvariable_for_function_creation = (\n    r\"!CT_DATA_DTYPE!_!CT_DATA_DTYPE2!_!C_FUNCTION_NAME!_!CT_DATA_DTYPE3!\"\n)\nappc = CreateCppDll(\n    cfunctioname=\"cppradixsort\",\n    cfunction=rf\"\"\"\n!DTYPE_EXPLANATIONC!\n__declspec(dllexport) void {variable_for_function_creation}\n(!C_DATA_DTYPE! * indatav1,size_t size, \n!C_DATA_DTYPE2! * indatav2, \n!C_DATA_DTYPE3! * outdatav )\n{{\n   std::vector\u003c!C_DATA_DTYPE!\u003e v(indatav1, \n   indatav1 + size);\n   concurrency::parallel_radixsort(begin(v), end(v));\n   std::copy(v.begin(), v.begin()+size, outdatav);\n}}\n\"\"\",\n    samedtypes=(\"!C_DATA_DTYPE!\", \"!C_DATA_DTYPE3!\"),\n    modulename=\"radixsortcpp\",\n    variable_for_function_creation=variable_for_function_creation,\n    cheader=\"\"\"\n    //#include \u003ciostream\u003e\n    //#include \u003cstdio.h\u003e\n    //#include \u003calgorithm\u003e    // std::replace_if\n    #include \u003cvector\u003e       // std::vector\n    //#include \u003cfunctional\u003e \n    //#include \u003cconio.h\u003e\n    #include \u003cppl.h\u003e\n\n    \"\"\",\n    cfooter=\"\",\n    ignored_dtypes1=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    ignored_dtypes2=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    ignored_dtypes3=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    vcvarsall_bat=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\",\n    cl_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\cl.exe\",\n    link_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\link.exe\",\n    compilerflags=(\"/std:c++17\", \"/Ferelease\", \"/EHsc\", \"/MT\", \"/O2\", \"/bigobj\"),\n)\nappc.compile_cpp_code()\n\n# compile and run\nfrom cinpy.radixsortcppmodule import cppradixsort\nimport numpy as np\narr1 = np.random.randint(0, 10000, 800000000)\narr2 = np.array([],dtype=arr1.dtype)\nsodi=cppradixsort(arr1,arr2,arr1.dtype)\n\nimport numpy as np\nfrom time import perf_counter\narr1 = np.random.randint(0, 10000, 800000000)\narr2 = np.array([],dtype=arr1.dtype)\nstart=perf_counter()\nsodi=cppradixsort(arr1,arr2,arr1.dtype)\nprint('c++: ', perf_counter()-start)\nstart=perf_counter()\nnp.sort(arr1)\nprint('numpy: ', perf_counter()-start)\nc++:  5.262247000000002\nnumpy:  36.521482199999994\n\n\nimport numpy as np\nfrom time import perf_counter\narr1 = np.random.randint(0, 10000, 800000000).tolist()\nstart=perf_counter()\narr1.sort()\nprint('python: ', perf_counter()-start)\npython:  158.9699383\n\n```\n\n\n\n```python\nfrom cinpy import CreateCppDll\n\nvariable_for_function_creation = (\n    r\"!CT_DATA_DTYPE!_!CT_DATA_DTYPE2!_!C_FUNCTION_NAME!_!CT_DATA_DTYPE3!\"\n)\nappc = CreateCppDll(\n    cfunctioname=\"cppbufferedsort\",\n    cfunction=rf\"\"\"\n!DTYPE_EXPLANATIONC!\n__declspec(dllexport) void {variable_for_function_creation}(!C_DATA_DTYPE! * indatav1,size_t size, !C_DATA_DTYPE2! * indatav2, !C_DATA_DTYPE3! * outdatav )\n{{\n   std::vector\u003c!C_DATA_DTYPE!\u003e v(indatav1, indatav1 + size);\n   concurrency::parallel_buffered_sort(begin(v), end(v));\n   std::copy(v.begin(), v.begin()+size, outdatav);\n}}\n\"\"\",\n    samedtypes=(\"!C_DATA_DTYPE!\", \"!C_DATA_DTYPE3!\"),\n    modulename=\"bufferedsortcpp\",\n    variable_for_function_creation=variable_for_function_creation,\n    cheader=\"\"\"\n    //#include \u003ciostream\u003e\n    //#include \u003cstdio.h\u003e\n    //#include \u003calgorithm\u003e    // std::replace_if\n    #include \u003cvector\u003e       // std::vector\n    //#include \u003cfunctional\u003e \n    //#include \u003cconio.h\u003e\n    #include \u003cppl.h\u003e\n\n    \"\"\",\n    cfooter=\"\",\n    ignored_dtypes1=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        # \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    ignored_dtypes2=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        # \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    ignored_dtypes3=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        # \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    vcvarsall_bat=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\",\n    cl_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\cl.exe\",\n    link_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\link.exe\",\n    compilerflags=(\"/std:c++17\", \"/Ferelease\", \"/EHsc\", \"/MT\", \"/O2\", \"/bigobj\"),\n)\nappc.compile_cpp_code()\n\n\"\"\"\n# Compile and run\nfrom cinpy.bufferedsortcppmodule import cppbufferedsort\nimport numpy as np\narr1 = np.random.random(8000000)\narr2 = np.array([],dtype=arr1.dtype)\n%timeit cppbufferedsort(arr1,arr2,arr1.dtype)\n%timeit np.sort(arr1)\n193 ms ± 7.74 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n568 ms ± 1.97 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n\ncppbufferedsort(arr1,arr2,arr1.dtype)\nOut[3]:\narray([5.84790262e-07, 6.10106611e-07, 6.50635063e-07, ...,\n       9.99999442e-01, 9.99999492e-01, 9.99999790e-01])\n\nnp.sort(arr1)\nOut[6]:\narray([5.84790262e-07, 6.10106611e-07, 6.50635063e-07, ...,\n       9.99999442e-01, 9.99999492e-01, 9.99999790e-01])\n\"\"\"\n```\n\n\n\n```python\n\n\nfrom cinpy import CreateCppDll\n\nvariable_for_function_creation = (\n    r\"!CT_DATA_DTYPE!_!CT_DATA_DTYPE2!_!C_FUNCTION_NAME!_!CT_DATA_DTYPE3!\"\n)\nappc = CreateCppDll(\n    cfunctioname=\"variouscalculations\",\n    cfunction=rf\"\"\"\n!DTYPE_EXPLANATIONC!\n__declspec(dllexport) void {variable_for_function_creation}(!C_DATA_DTYPE! * indatav1,size_t size, !C_DATA_DTYPE2! * indatav2, !C_DATA_DTYPE3! * outdatav )\n{{\n        concurrency::parallel_for (size_t(0), size, [\u0026](size_t u){{\n        outdatav[u] = indatav1[u] * indatav2[0] / indatav2[1] + indatav2[2] - indatav2[3];}});\n}}\n\"\"\",\n    samedtypes=(),\n    modulename=\"calcvarious\",\n    variable_for_function_creation=variable_for_function_creation,\n    cheader=\"\"\"\n    //#include \u003ciostream\u003e\n    //#include \u003cstdio.h\u003e\n    //#include \u003calgorithm\u003e    // std::replace_if\n    //#include \u003cvector\u003e       // std::vector\n    //#include \u003cfunctional\u003e \n    //#include \u003cconio.h\u003e\n    #include \u003cppl.h\u003e\n\n    \"\"\",\n    cfooter=\"\",\n    ignored_dtypes1=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        # \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    ignored_dtypes2=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        # \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    ignored_dtypes3=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        # \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    vcvarsall_bat=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\",\n    cl_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\cl.exe\",\n    link_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\link.exe\",\n    compilerflags=(\"/std:c++17\", \"/Ferelease\", \"/EHsc\", \"/MT\", \"/O2\", \"/bigobj\"),\n)\nappc.compile_cpp_code()\n\n\n# Compile the code and run:\nfrom cinpy.calcvariousmodule import variouscalculations\nimport numpy as np\ninputarray3np = np.random.randint(0, 10000000, 1000000).astype(np.float64)\ninputarray4np = np.array([40.2901,4.21,2.12,6.3])\ncp=variouscalculations(inputarray3np,inputarray4np,np.float64)\nnu= inputarray3np *40.2901/4.21+2.12-6.3\n\nprint(cp)\nprint(nu)\n[15388258.80463183 85115406.42555821 75231240.03558196 ...\n 34228493.34042756 68792824.6350119  86092819.36931117]\n[15388258.80463183 85115406.42555821 75231240.03558196 ...\n 34228493.34042756 68792824.6350119  86092819.36931117]\n \n%timeit variouscalculations(inputarray3np,inputarray4np,np.float64)\n2.04 ms ± 124 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n%timeit inputarray3np *40.2901/4.21+2.12-6.3\n10.2 ms ± 63.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n\n\n```\n\n\n\n\n\n```python\nfrom cinpy import CreateCppDll\n\nvariable_for_function_creation = (\n    r\"!CT_DATA_DTYPE!_!CT_DATA_DTYPE2!_!C_FUNCTION_NAME!_!CT_DATA_DTYPE3!\"\n)\nappc = CreateCppDll(\n    cfunctioname=\"multiplybyarray\",\n    cfunction=rf\"\"\"\n!DTYPE_EXPLANATIONC!\n__declspec(dllexport) void {variable_for_function_creation}(!C_DATA_DTYPE! * indatav1,size_t size, !C_DATA_DTYPE2! * indatav2, !C_DATA_DTYPE3! * outdatav )\n{{\n        concurrency::parallel_for (size_t(0), size, [\u0026](size_t u){{\n        outdatav[u] = indatav1[u] * indatav2[u];}});\n}}\n\"\"\",\n    samedtypes=(),\n    modulename=\"multiplyarrays\",\n    variable_for_function_creation=variable_for_function_creation,\n    cheader=\"\"\"\n    //#include \u003ciostream\u003e\n    //#include \u003cstdio.h\u003e\n    //#include \u003calgorithm\u003e    // std::replace_if\n    //#include \u003cvector\u003e       // std::vector\n    //#include \u003cfunctional\u003e \n    //#include \u003cconio.h\u003e\n    #include \u003cppl.h\u003e\n\n    \"\"\",\n    cfooter=\"\",\n    ignored_dtypes1=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        # \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    ignored_dtypes2=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        # \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    ignored_dtypes3=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        # \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    vcvarsall_bat=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\",\n    cl_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\cl.exe\",\n    link_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\link.exe\",\n    compilerflags=(\"/std:c++17\", \"/Ferelease\", \"/EHsc\", \"/MT\", \"/O2\", \"/bigobj\"),\n)\nappc.compile_cpp_code()\n\n\n# compile and run\nfrom cinpy.multiplyarraysmodule import multiplybyarray\nimport numpy as np\ninputarray3np = np.random.randint(0, 1005000, 8000000).astype(np.uint64)\ninputarray4np = np.random.randint(0, 1022300, 8000000).astype(np.uint64)\n%timeit multiplybyarray(inputarray3np,inputarray4np,np.uint64)\n%timeit inputarray3np*inputarray4np\n18.1 ms ± 757 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n26.6 ms ± 163 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n\nmultiplybyarray(inputarray3np,inputarray4np,np.uint64)\nOut[4]:\narray([218000641625, 493834462272,  38299985966, ...,  74381999748,\n       168393582760, 515058090867], dtype=uint64)\ninputarray3np*inputarray4np\nOut[5]:\narray([218000641625, 493834462272,  38299985966, ...,  74381999748,\n       168393582760, 515058090867], dtype=uint64)\n\n```\n\n```python\n\n\nfrom cinpy import CreateCppDll\n\nvariable_for_function_creation = (\n    r\"!CT_DATA_DTYPE!_!CT_DATA_DTYPE2!_!C_FUNCTION_NAME!_!CT_DATA_DTYPE3!\"\n)\nappc = CreateCppDll(\n    cfunctioname=\"multiplybynumber\",\n    cfunction=rf\"\"\"\n!DTYPE_EXPLANATIONC!\n__declspec(dllexport) void {variable_for_function_creation}(!C_DATA_DTYPE! * indatav1,size_t size, !C_DATA_DTYPE2! * indatav2, !C_DATA_DTYPE3! * outdatav )\n{{\n        concurrency::parallel_for (size_t(0), size, [\u0026](size_t u){{\n        outdatav[u] = indatav1[u] * indatav2[0];}});\n}}\n\"\"\",\nsamedtypes=(),\n    modulename=\"mulbyonenumber\",\n    variable_for_function_creation=variable_for_function_creation,\n    cheader=\"\"\"\n    //#include \u003ciostream\u003e\n    //#include \u003cstdio.h\u003e\n    //#include \u003calgorithm\u003e    // std::replace_if\n    //#include \u003cvector\u003e       // std::vector\n    //#include \u003cfunctional\u003e \n    //#include \u003cconio.h\u003e\n    #include \u003cppl.h\u003e\n\n    \"\"\",\n    cfooter=\"\",\n    ignored_dtypes1=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        # \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    ignored_dtypes2=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        # \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    ignored_dtypes3=(\n        \"bool\",\n        # \"signed char\",\n        # \"unsigned char\",\n        # \"short\",\n        # \"unsigned short\",\n        # \"int\",\n        # \"unsigned int\",\n        # \"long\",\n        # \"unsigned long\",\n        # \"long long\",\n        # \"unsigned long long\",\n        \"float\",\n        # \"double\",\n        \"long double\",\n        \"float complex\",\n        \"double complex\",\n        \"long double complex\",\n    ),\n    vcvarsall_bat=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\",\n    cl_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\cl.exe\",\n    link_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\link.exe\",\n    compilerflags=(\"/std:c++17\", \"/Ferelease\", \"/EHsc\", \"/MT\", \"/O2\", \"/bigobj\"),\n)\nappc.compile_cpp_code()\n\n# compile and run\n\nfrom cinpy.mulbyonenumbermodule import multiplybynumber\nimport numpy as np\ninputarray3np = np.random.randint(0, 100000, 8000000).astype(np.float64)\ninputarray4np = np.array([2.345122],dtype=np.float64)\n%timeit multiplybynumber(inputarray3np,inputarray4np,np.float64)\n%timeit inputarray3np*inputarray4np[0]\n14.5 ms ± 99 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n22.1 ms ± 131 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n\nmultiplybynumber(inputarray3np,inputarray4np,np.float64)\nOut[10]:\narray([221388.897288, 123871.689162,  40683.176456, ..., 222221.415598,\n        73761.122266,  69851.803892])\ninputarray3np*inputarray4np[0]\nOut[11]:\narray([221388.897288, 123871.689162,  40683.176456, ..., 222221.415598,\n        73761.122266,  69851.803892])\n\n\n\n# There is also a second version (if you need to pass more variables)\n\nfrom cinpy import CreateCppDllv2\n\ncppco = CreateCppDllv2(\n    modulename=\"cppsort\",\n    # \"module\" will be added to \"cppsort\"\n    # This is how to import it after compiling the code:\n    # from cinpy.cppsortmodule import cppradixsort\n    cheader=\"\"\"\n#include \u003cvector\u003e       // std::vector\n#include \u003cppl.h\u003e\n\n\"\"\",  # Code before the functions in the .cpp file -\u003e imports etc.\n    cfooter=\"\",  # Code after the functions in the .cpp file\n    cfunctioname=\"cppradixsort\",\n    # This is the name of the C++ function in Python, this is how you import it:\n    # from cinpy.cppsortmodule import cppradixsort\n    var_variations={\n        # cinpy creates various versions of the functions (I could not make\n        # templates/function overloading work with Python) Create a dict with\n        # all datadtypes that you want to use for each variable\n        \"!C_DATA_DTYPE1!\": (  # \"bool\",\n            \"signed char\",\n            \"unsigned char\",\n            \"short\",\n            \"unsigned short\",\n            \"int\",\n            \"unsigned int\",\n            \"long\",\n            \"unsigned long\",\n            \"long long\",\n            \"unsigned long long\",  # \"float\",\n            # \"double\",\n            # \"long double\",\n            # \"float complex\",\n            # \"double complex\",\n            # \"long double complex\",\n        ),\n        \"!C_DATA_DTYPE2!\": (\"size_t\",),\n        \"!C_DATA_DTYPE3!\": (  # \"bool\",\n            \"signed char\",\n            \"unsigned char\",\n            \"short\",\n            \"unsigned short\",\n            \"int\",\n            \"unsigned int\",\n            \"long\",\n            \"unsigned long\",\n            \"long long\",\n            \"unsigned long long\",  # \"float\",\n            # \"double\",\n            # \"long double\",\n            # \"float complex\",\n            # \"double complex\",\n            # \"long double complex\",\n        ),\n        \"!C_DATA_DTYPE4!\": (\"size_t\",),\n        \"!C_DATA_DTYPE5!\": (  # \"bool\",\n            \"signed char\",\n            \"unsigned char\",\n            \"short\",\n            \"unsigned short\",\n            \"int\",\n            \"unsigned int\",\n            \"long\",\n            \"unsigned long\",\n            \"long long\",\n            \"unsigned long long\",  # \"float\",\n            # \"double\",\n            # \"long double\",\n            # \"float complex\",\n            # \"double complex\",\n            # \"long double complex\",\n        ),\n        \"!C_DATA_DTYPE6!\": (\"size_t\",),\n    },\n    dtypemustbeequal=[(\"!C_DATA_DTYPE1!\", \"!C_DATA_DTYPE3!\", \"!C_DATA_DTYPE5!\")],\n    # \"!C_DATA_DTYPE1!\", \"!C_DATA_DTYPE3!\", \"!C_DATA_DTYPE5!\" will always have the same Datatype\n    fu=rf\"\"\"\n__declspec(dllexport) void variable_for_function_creation\n(!C_DATA_DTYPE1! * indatav1,!C_DATA_DTYPE2!  size1,\n!C_DATA_DTYPE3! * indatav2,!C_DATA_DTYPE4!  size2,\n!C_DATA_DTYPE5! * indatav3,!C_DATA_DTYPE6! size3  )\n{{\n   std::vector\u003c!C_DATA_DTYPE1!\u003e v(indatav1,\n   indatav1 + size1);\n   concurrency::parallel_radixsort(begin(v), end(v));\n   std::copy(v.begin(), v.begin()+size1, indatav3);\n\n   std::vector\u003c!C_DATA_DTYPE1!\u003e v2(indatav1, indatav1 + size1);\n   concurrency::parallel_buffered_sort(begin(v2), end(v2));\n   std::copy(v2.begin(), v2.begin()+size1, indatav2);\n\n\n}}\"\"\",\n    # The C++ code, use the keys in the dict for the data types, don't change the function name:  variable_for_function_creation\n)\ncppco.compile_cpp_code(\n    vcvarsall_bat=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\",\n    cl_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\cl.exe\",\n    link_exe=r\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\Hostx86\\x64\\link.exe\",\n    compilerflags=(\"/std:c++20\", \"/Ferelease\", \"/EHsc\", \"/MT\", \"/O2\", \"/bigobj\"),\n) # Compile the code\n\n#import the compiled code\n\nfrom cinpy.cppsortmodule import cppradixsort\nimport numpy as np\ninputarray = np.array([6,3,2,64,2,46],dtype=np.uint8)\nnpbufferedsort = np.zeros_like(inputarray)\nnpradixsort = np.zeros_like(inputarray)\nlen1=inputarray.size\nlen2=npbufferedsort.size\nlen3=npradixsort.size\n# arguments always start with v + number, data dtype should be detected automatically\ncppradixsort(v0=inputarray,v1=len1,v2=npbufferedsort,v3=len2,v4=npradixsort,v5=len3,)\nprint(inputarray)\nprint(npbufferedsort)\nprint(npradixsort)\n\n# results\n# [ 6  3  2 64  2 46]\n# [ 2  2  3  6 46 64]\n# [ 2  2  3  6 46 64]\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansalemaos%2Fcinpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhansalemaos%2Fcinpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansalemaos%2Fcinpy/lists"}