{"id":15973719,"url":"https://github.com/c-bata/mypyc_ipython","last_synced_at":"2025-03-18T00:30:52.082Z","repository":{"id":63017417,"uuid":"303595852","full_name":"c-bata/mypyc_ipython","owner":"c-bata","description":"IPython magic command interface for interactive work with mypyc, a compiler from type-annotated Python to C extensions.","archived":false,"fork":false,"pushed_at":"2023-08-22T15:26:21.000Z","size":13,"stargazers_count":7,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-28T05:57:52.743Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pypi.org/project/mypyc-ipython/","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/c-bata.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}},"created_at":"2020-10-13T05:19:48.000Z","updated_at":"2024-06-09T15:35:59.000Z","dependencies_parsed_at":"2024-10-27T17:09:36.094Z","dependency_job_id":null,"html_url":"https://github.com/c-bata/mypyc_ipython","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Fmypyc_ipython","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Fmypyc_ipython/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Fmypyc_ipython/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Fmypyc_ipython/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c-bata","download_url":"https://codeload.github.com/c-bata/mypyc_ipython/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243893849,"owners_count":20364918,"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-10-07T21:06:37.826Z","updated_at":"2025-03-18T00:30:51.268Z","avatar_url":"https://github.com/c-bata.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mypyc_ipython\n\nIPython magic command interface for interactive work with [mypyc](https://github.com/python/mypy), a compiler from type-annotated Python to C extensions.\n\n## Installation\n\nSupported Python versions are 3.6 or later.\n\n```console\n$ pip install mypyc-ipython\n```\n\n## Usage\n\nYou can use this library like [``%%cython`` magic command](https://cython.readthedocs.io/en/latest/src/quickstart/build.html#using-the-jupyter-notebook).\n\n1. Execute ``%load_ext mypyc_ipython`` to enable the magic.\n2. Write the code in ``%%mypyc`` code cell.\n\n```python\nIn [1]: %load_ext mypyc_ipython\n\nIn [2]: %%mypyc\n   ...: def my_fibonacci(n: int) -\u003e int:\n   ...:     if n \u003c= 2:\n   ...:         return 1\n   ...:     else:\n   ...:         return my_fibonacci(n-1) + my_fibonacci(n-2)\n   ...:\n\nIn [3]: my_fibonacci(10)\nOut[3]: 55\n\nIn [4]: def py_fibonacci(n: int) -\u003e int:\n   ...:     if n \u003c= 2:\n   ...:         return 1\n   ...:     else:\n   ...:         return py_fibonacci(n-1) + py_fibonacci(n-2)\n   ...:\n\nIn [5]: py_fibonacci(10)\nOut[5]: 55\n\nIn [6]: %load_ext cython\n\nIn [7]: %%cython\n   ...: cpdef int cy_fibonacci(int n):\n   ...:     if n \u003c= 2:\n   ...:         return 1\n   ...:     else:\n   ...:         return cy_fibonacci(n-1) + cy_fibonacci(n-2)\n   ...:\n\nIn [8]: cy_fibonacci(10)\nOut[8]: 55\n\nIn [9]: %timeit py_fibonacci(10)\n10.3 µs ± 30.2 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n\nIn [10]: %timeit my_fibonacci(10)\n848 ns ± 5.82 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)\n\nIn [11]: %timeit cy_fibonacci(10)\n142 ns ± 1.18 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n\nIn [12]:\n```\n\nThe contents of the cell are written to a `.py` file in the directory `IPYTHONDIR/mypyc`\nusing a filename with the hash of the code. This file is then mypycified and compiled.\nThe resulting module is imported and all of its symbols are injected into the user's namespace.\n\nIf you want to disable the cache, you can use ``--force`` option like this:\n\n```python\nIn [2]: %%mypyc --force\n   ...: def my_fibonacci(n: int) -\u003e int:\n   ...:     if n \u003c= 2:\n   ...:         return 1\n   ...:     else:\n   ...:         return my_fibonacci(n-1) + my_fibonacci(n-2)\n```\n\n## Author\n\nMasashi Shibata ([@c-bata](https://github.com/c-bata))\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-bata%2Fmypyc_ipython","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc-bata%2Fmypyc_ipython","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-bata%2Fmypyc_ipython/lists"}