{"id":13398364,"url":"https://github.com/pydata/numexpr","last_synced_at":"2025-05-14T07:02:40.606Z","repository":{"id":12221248,"uuid":"14829536","full_name":"pydata/numexpr","owner":"pydata","description":"Fast numerical array expression evaluator for Python, NumPy, Pandas, PyTables and more","archived":false,"fork":false,"pushed_at":"2025-04-26T06:17:25.000Z","size":2804,"stargazers_count":2296,"open_issues_count":2,"forks_count":213,"subscribers_count":58,"default_branch":"master","last_synced_at":"2025-05-07T06:17:18.737Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://numexpr.readthedocs.io/en/latest/user_guide.html","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/pydata.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.txt","dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"FrancescAlted"}},"created_at":"2013-11-30T22:33:48.000Z","updated_at":"2025-05-06T04:52:11.000Z","dependencies_parsed_at":"2023-01-14T05:15:33.638Z","dependency_job_id":"58edea33-f83f-4f7a-bd5f-1984f57a0711","html_url":"https://github.com/pydata/numexpr","commit_stats":{"total_commits":776,"total_committers":75,"mean_commits":"10.346666666666666","dds":0.6559278350515464,"last_synced_commit":"2378606e4d8a0daf1bdc97512256953bffc8403f"},"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydata%2Fnumexpr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydata%2Fnumexpr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydata%2Fnumexpr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydata%2Fnumexpr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pydata","download_url":"https://codeload.github.com/pydata/numexpr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253692565,"owners_count":21948322,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-07-30T19:00:23.892Z","updated_at":"2025-05-14T07:02:40.560Z","avatar_url":"https://github.com/pydata.png","language":"Python","readme":"======================================================\nNumExpr: Fast numerical expression evaluator for NumPy\n======================================================\n\n:Author: David M. Cooke, Francesc Alted, and others.\n:Maintainer: Francesc Alted\n:Contact: faltet@gmail.com\n:URL: https://github.com/pydata/numexpr\n:Documentation: http://numexpr.readthedocs.io/en/latest/\n:GitHub Actions: |actions|\n:PyPi: |version|\n:DOI: |doi|\n:readthedocs: |docs|\n\n.. |actions| image:: https://github.com/pydata/numexpr/workflows/Build/badge.svg\n        :target: https://github.com/pydata/numexpr/actions\n.. |travis| image:: https://travis-ci.org/pydata/numexpr.png?branch=master\n        :target: https://travis-ci.org/pydata/numexpr\n.. |docs| image:: https://readthedocs.org/projects/numexpr/badge/?version=latest\n        :target: http://numexpr.readthedocs.io/en/latest\n.. |doi| image:: https://zenodo.org/badge/doi/10.5281/zenodo.2483274.svg\n        :target:  https://doi.org/10.5281/zenodo.2483274\n.. |version| image:: https://img.shields.io/pypi/v/numexpr\n        :target: https://pypi.python.org/pypi/numexpr\n\n\nWhat is NumExpr?\n----------------\n\nNumExpr is a fast numerical expression evaluator for NumPy.  With it,\nexpressions that operate on arrays (like :code:`'3*a+4*b'`) are accelerated\nand use less memory than doing the same calculation in Python.\n\nIn addition, its multi-threaded capabilities can make use of all your\ncores -- which generally results in substantial performance scaling compared\nto NumPy.\n\nLast but not least, numexpr can make use of Intel's VML (Vector Math\nLibrary, normally integrated in its Math Kernel Library, or MKL).\nThis allows further acceleration of transcendent expressions.\n\n\nHow NumExpr achieves high performance\n-------------------------------------\n\nThe main reason why NumExpr achieves better performance than NumPy is\nthat it avoids allocating memory for intermediate results. This\nresults in better cache utilization and reduces memory access in\ngeneral. Due to this, NumExpr works best with large arrays.\n\nNumExpr parses expressions into its own op-codes that are then used by\nan integrated computing virtual machine. The array operands are split\ninto small chunks that easily fit in the cache of the CPU and passed\nto the virtual machine. The virtual machine then applies the\noperations on each chunk. It's worth noting that all temporaries and\nconstants in the expression are also chunked. Chunks are distributed among\nthe available cores of the CPU, resulting in highly parallelized code\nexecution.\n\nThe result is that NumExpr can get the most of your machine computing\ncapabilities for array-wise computations. Common speed-ups with regard\nto NumPy are usually between 0.95x (for very simple expressions like\n:code:`'a + 1'`) and 4x (for relatively complex ones like :code:`'a*b-4.1*a \u003e 2.5*b'`),\nalthough much higher speed-ups can be achieved for some functions  and complex\nmath operations (up to 15x in some cases).\n\nNumExpr performs best on matrices that are too large to fit in L1 CPU cache.\nIn order to get a better idea on the different speed-ups that can be achieved\non your platform, run the provided benchmarks.\n\nInstallation\n------------\n\nFrom wheels\n^^^^^^^^^^^\n\nNumExpr is available for install via `pip` for a wide range of platforms and\nPython versions (which may be browsed at: https://pypi.org/project/numexpr/#files).\nInstallation can be performed as::\n\n    pip install numexpr\n\nIf you are using the Anaconda or Miniconda distribution of Python you may prefer\nto use the `conda` package manager in this case::\n\n    conda install numexpr\n\nFrom Source\n^^^^^^^^^^^\n\nOn most \\*nix systems your compilers will already be present. However if you\nare using a virtual environment with a substantially newer version of Python than\nyour system Python you may be prompted to install a new version of `gcc` or `clang`.\n\nFor Windows, you will need to install the Microsoft Visual C++ Build Tools\n(which are free) first. The version depends on which version of Python you have\ninstalled:\n\nhttps://wiki.python.org/moin/WindowsCompilers\n\nFor Python 3.6+ simply installing the latest version of MSVC build tools should\nbe sufficient. Note that wheels found via pip do not include MKL support. Wheels\navailable via `conda` will have MKL, if the MKL backend is used for NumPy.\n\nSee `requirements.txt` for the required version of NumPy.\n\nNumExpr is built in the standard Python way::\n\n  python setup.py build install\n\nYou can test `numexpr` with::\n\n  python -c \"import numexpr; numexpr.test()\"\n\nDo not test NumExpr in the source directory or you will generate import errors.\n\nEnable Intel® MKL support\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\nNumExpr includes support for Intel's MKL library. This may provide better\nperformance on Intel architectures, mainly when evaluating transcendental\nfunctions (trigonometrical, exponential, ...).\n\nIf you have Intel's MKL, copy the `site.cfg.example` that comes with the\ndistribution to `site.cfg` and edit the latter file to provide correct paths to\nthe MKL libraries in your system.  After doing this, you can proceed with the\nusual building instructions listed above.\n\nPay attention to the messages during the building process in order to know\nwhether MKL has been detected or not.  Finally, you can check the speed-ups on\nyour machine by running the `bench/vml_timing.py` script (you can play with\ndifferent parameters to the `set_vml_accuracy_mode()` and `set_vml_num_threads()`\nfunctions in the script so as to see how it would affect performance).\n\nUsage\n-----\n\n::\n\n  \u003e\u003e\u003e import numpy as np\n  \u003e\u003e\u003e import numexpr as ne\n\n  \u003e\u003e\u003e a = np.arange(1e6)   # Choose large arrays for better speedups\n  \u003e\u003e\u003e b = np.arange(1e6)\n\n  \u003e\u003e\u003e ne.evaluate(\"a + 1\")   # a simple expression\n  array([  1.00000000e+00,   2.00000000e+00,   3.00000000e+00, ...,\n           9.99998000e+05,   9.99999000e+05,   1.00000000e+06])\n\n  \u003e\u003e\u003e ne.evaluate(\"a * b - 4.1 * a \u003e 2.5 * b\")   # a more complex one\n  array([False, False, False, ...,  True,  True,  True], dtype=bool)\n\n  \u003e\u003e\u003e ne.evaluate(\"sin(a) + arcsinh(a/b)\")   # you can also use functions\n  array([        NaN,  1.72284457,  1.79067101, ...,  1.09567006,\n          0.17523598, -0.09597844])\n\n  \u003e\u003e\u003e s = np.array([b'abba', b'abbb', b'abbcdef'])\n  \u003e\u003e\u003e ne.evaluate(\"b'abba' == s\")   # string arrays are supported too\n  array([ True, False, False], dtype=bool)\n\n\nFree-threading support\n----------------------\nStarting on CPython 3.13 onwards there is a new distribution that disables the\nGlobal Interpreter Lock (GIL) altogether, thus increasing the performance yields\nunder multi-threaded conditions on a single interpreter, as opposed to having to use\nmultiprocessing.\n\nWhilst numexpr has been demonstrated to work under free-threaded\nCPython, considerations need to be taken when using numexpr native parallel\nimplementation vs using Python threads directly in order to prevent oversubscription,\nwe recommend either using the main CPython interpreter thread to spawn multiple C threads\nusing the parallel numexpr API, or spawning multiple CPython threads that do not use\nthe parallel API.\n\nFor more information about free-threaded CPython, we recommend visiting the following\n`community Wiki \u003chttps://py-free-threading.github.io/\u003e`\n\n\nDocumentation\n-------------\n\nPlease see the official documentation at `numexpr.readthedocs.io \u003chttps://numexpr.readthedocs.io\u003e`_.\nIncluded is a user guide, benchmark results, and the reference API.\n\n\nAuthors\n-------\n\nPlease see `AUTHORS.txt \u003chttps://github.com/pydata/numexpr/blob/master/AUTHORS.txt\u003e`_.\n\n\nLicense\n-------\n\nNumExpr is distributed under the `MIT \u003chttp://www.opensource.org/licenses/mit-license.php\u003e`_ license.\n\n\n.. Local Variables:\n.. mode: text\n.. coding: utf-8\n.. fill-column: 70\n.. End:\n","funding_links":["https://github.com/sponsors/FrancescAlted"],"categories":["Computations","Basic Components","Python","Linear Algebra / Statistics Toolkit","Ecosystem","数据容器和结构","ریاضی","Scientific","Data Containers \u0026 Dataframes"],"sub_categories":["NLP","Python Performance Booster","Synthetic Data","General Purpose Tensor Library","Extended library","کار با زمان و تقویم"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpydata%2Fnumexpr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpydata%2Fnumexpr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpydata%2Fnumexpr/lists"}