django-cythonizer


Namedjango-cythonizer JSON
Version 0.0.12 PyPI version JSON
download
home_pagehttps://github.com/salah-alhajj/django-cythonizer
SummaryA Django package for Cythonizing Django projects
upload_time2024-07-19 15:33:32
maintainerNone
docs_urlNone
authorSalah Aldain Alhajj
requires_python>=3.6
licenseMIT License with Usage Disclosure Copyright (c) 2024 Salah Aldain Alhajj Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 2. Users of this Software must disclose the use of django-cythonizer in their project documentation or in a file named THIRD-PARTY-NOTICES (or similar) that accompanies the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords django cython optimization performance compilation
VCS
bugtrack_url
requirements Cython Django djangorestframework PyYAML
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django-Cythonizer 🚀

![Django-Cythonizer Logo](https://raw.githubusercontent.com/salah-alhajj/django-cythonizer/main/Cython_logo.svg?token=GHSAT0AAAAAACT36IXH3OKDLE7OCUBENUZGZU2FRXQ)

<p align="center">
  <a href="https://badge.fury.io/py/django-cythonizer">
    <img src="https://badge.fury.io/py/django-cythonizer.svg" alt="PyPI version" />
  </a>
  <a href="https://pypi.org/project/django-cythonizer/">
    <img src="https://img.shields.io/pypi/pyversions/django-cythonizer.svg" alt="Python Versions" />
  </a>
  <a href="https://www.djangoproject.com/">
    <img src="https://img.shields.io/badge/django-3.2%20%7C%204.0%20%7C%204.1%20%7C%204.2-blue" alt="Django Versions" />
  </a>
  <a href="https://opensource.org/licenses/MIT">
    <img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" />
  </a>
  <a href="https://github.com/salah-alhajj/django-cythonizer/actions">
    <img src="https://github.com/salah-alhajj/django-cythonizer/workflows/Build/badge.svg" alt="Build Status" />
  </a>
  <a href="https://codecov.io/gh/salah-alhajj/django-cythonizer">
    <img src="https://codecov.io/gh/salah-alhajj/django-cythonizer/branch/main/graph/badge.svg" alt="codecov" />
  </a>
</p>


Supercharge your Django project with the power of Cython! 🐍💨

## 🌟 Features

- 🚀 Automatically compile Django views and models to Cython
- 📈 Boost performance by up to 30% (results may vary)
- 🛠 Easy integration with existing Django projects
- 🔒 Secure your Python source code
- 🔧 Customizable compilation settings

## 🚀 Quick Start

### Installation

```bash
pip install django-cythonizer
```

### Usage

1. Add 'cythonizer' to your INSTALLED_APPS:

```python
INSTALLED_APPS = [
    # ...
    'cythonizer',
    # ...
]
```

2. Run the cythonize command:

```bash
python manage.py cythonize
```

3. Open build FLoder and run it as normal django project 
<br>
4. Enjoy the speed boost! 🎉🎉🎉🎉
<br/>
## ⚠️ Important Considerations

### Handling Excluded Paths

- **Virtual Environments**: The `.venv` directory is excluded by default.
- **Migration Files**: The `migrations` folders are excluded to avoid issues with Django's migration system.
- **Configuration Files**: Sensitive files like `settings.py` and `urls.py` are excluded.

### Other Considerations

- Always test your project after compilation to ensure no unexpected errors occur.
- Keep a backup of your original code before applying compilation on a large scale.

## 🔧 Configuration

The `settings.yaml` file in your project root controls the cythonizer behavior:

```yaml
build:
  path: 'build'

exclude:
  files:
    - 'setup.py'
    - '__init__.py'
    - 'manage.py'
    - 'urls.py'
    - '.gitigonre'
    - '.git'
  dirs:
    - 'migrations'
    - '.venv'
    - 'build'

# ... (other settings)
```

## 🔥 Performance Comparison

Here's a quick benchmark comparing a standard Django view vs a Cythonized view:

| Scenario   | Requests/sec | Latency (ms) |
|------------|--------------|--------------|
| Standard   | 1000         | 50           |
| Cythonized | 1300         | 38           |

As the load increases on the system, the performance and reliability gap between the standard Django project and the Cythonized Django project widens, with the Cythonized version consistently outperforming, despite both projects being identical in terms of code and environment.

## 🛠 How It Works

1. **Analysis**: Django-Cythonizer scans your project structure.
2. **Compilation**: It compiles eligible Python files to Cython.
3. **Integration**: The compiled modules seamlessly replace the original ones.
4. **Optimization**: Enjoy the performance benefits!

## 🤔 FAQs

<details>
<summary>Is it compatible with all Django versions?</summary>
Django-Cythonizer supports Django 3.2 and above, as specified in the project requirements.
</details>

<details>
<summary>Will it break my existing code?</summary>
No, Django-Cythonizer is designed to be non-intrusive. Your original Python files remain untouched.
</details>

<details>
<summary>Can I use it in production?</summary>
Absolutely! Many projects use Cython in production to great effect. Always thoroughly test before deploying.
</details>

## 🤝 Contributing

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for more details.

## 📜 License

Django-Cythonizer is released under the MIT License. See the [LICENSE](LICENSE) file for more details.

## 🙏 Acknowledgements

- The amazing Django community
- The Cython team for their incredible work
- All our contributors and users

## 📬 Contact

For support or queries, reach out to us at [contact@salahaldain.com](mailto:contact@salahaldain.com).


---
<br>
<p align="center">
  Made with ❤️ by developers, for developers.<br>
  Initiated by <a href="https://github.com/salah-alhajj">Salah Aldain Alhajj</a>
</p>


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/salah-alhajj/django-cythonizer",
    "name": "django-cythonizer",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "django, cython, optimization, performance, compilation",
    "author": "Salah Aldain Alhajj",
    "author_email": "Salah Aldain Alhajj <contact@salahaldain.com>",
    "download_url": "https://files.pythonhosted.org/packages/52/24/536dedfe361c23bed8f6e6e6c945e387d406b25f25aa1adcafcec80b4f8b/django_cythonizer-0.0.12.tar.gz",
    "platform": null,
    "description": "# Django-Cythonizer \ud83d\ude80\n\n![Django-Cythonizer Logo](https://raw.githubusercontent.com/salah-alhajj/django-cythonizer/main/Cython_logo.svg?token=GHSAT0AAAAAACT36IXH3OKDLE7OCUBENUZGZU2FRXQ)\n\n<p align=\"center\">\n  <a href=\"https://badge.fury.io/py/django-cythonizer\">\n    <img src=\"https://badge.fury.io/py/django-cythonizer.svg\" alt=\"PyPI version\" />\n  </a>\n  <a href=\"https://pypi.org/project/django-cythonizer/\">\n    <img src=\"https://img.shields.io/pypi/pyversions/django-cythonizer.svg\" alt=\"Python Versions\" />\n  </a>\n  <a href=\"https://www.djangoproject.com/\">\n    <img src=\"https://img.shields.io/badge/django-3.2%20%7C%204.0%20%7C%204.1%20%7C%204.2-blue\" alt=\"Django Versions\" />\n  </a>\n  <a href=\"https://opensource.org/licenses/MIT\">\n    <img src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" alt=\"License: MIT\" />\n  </a>\n  <a href=\"https://github.com/salah-alhajj/django-cythonizer/actions\">\n    <img src=\"https://github.com/salah-alhajj/django-cythonizer/workflows/Build/badge.svg\" alt=\"Build Status\" />\n  </a>\n  <a href=\"https://codecov.io/gh/salah-alhajj/django-cythonizer\">\n    <img src=\"https://codecov.io/gh/salah-alhajj/django-cythonizer/branch/main/graph/badge.svg\" alt=\"codecov\" />\n  </a>\n</p>\n\n\nSupercharge your Django project with the power of Cython! \ud83d\udc0d\ud83d\udca8\n\n## \ud83c\udf1f Features\n\n- \ud83d\ude80 Automatically compile Django views and models to Cython\n- \ud83d\udcc8 Boost performance by up to 30% (results may vary)\n- \ud83d\udee0 Easy integration with existing Django projects\n- \ud83d\udd12 Secure your Python source code\n- \ud83d\udd27 Customizable compilation settings\n\n## \ud83d\ude80 Quick Start\n\n### Installation\n\n```bash\npip install django-cythonizer\n```\n\n### Usage\n\n1. Add 'cythonizer' to your INSTALLED_APPS:\n\n```python\nINSTALLED_APPS = [\n    # ...\n    'cythonizer',\n    # ...\n]\n```\n\n2. Run the cythonize command:\n\n```bash\npython manage.py cythonize\n```\n\n3. Open build FLoder and run it as normal django project \n<br>\n4. Enjoy the speed boost! \ud83c\udf89\ud83c\udf89\ud83c\udf89\ud83c\udf89\n<br/>\n## \u26a0\ufe0f Important Considerations\n\n### Handling Excluded Paths\n\n- **Virtual Environments**: The `.venv` directory is excluded by default.\n- **Migration Files**: The `migrations` folders are excluded to avoid issues with Django's migration system.\n- **Configuration Files**: Sensitive files like `settings.py` and `urls.py` are excluded.\n\n### Other Considerations\n\n- Always test your project after compilation to ensure no unexpected errors occur.\n- Keep a backup of your original code before applying compilation on a large scale.\n\n## \ud83d\udd27 Configuration\n\nThe `settings.yaml` file in your project root controls the cythonizer behavior:\n\n```yaml\nbuild:\n  path: 'build'\n\nexclude:\n  files:\n    - 'setup.py'\n    - '__init__.py'\n    - 'manage.py'\n    - 'urls.py'\n    - '.gitigonre'\n    - '.git'\n  dirs:\n    - 'migrations'\n    - '.venv'\n    - 'build'\n\n# ... (other settings)\n```\n\n## \ud83d\udd25 Performance Comparison\n\nHere's a quick benchmark comparing a standard Django view vs a Cythonized view:\n\n| Scenario   | Requests/sec | Latency (ms) |\n|------------|--------------|--------------|\n| Standard   | 1000         | 50           |\n| Cythonized | 1300         | 38           |\n\nAs the load increases on the system, the performance and reliability gap between the standard Django project and the Cythonized Django project widens, with the Cythonized version consistently outperforming, despite both projects being identical in terms of code and environment.\n\n## \ud83d\udee0 How It Works\n\n1. **Analysis**: Django-Cythonizer scans your project structure.\n2. **Compilation**: It compiles eligible Python files to Cython.\n3. **Integration**: The compiled modules seamlessly replace the original ones.\n4. **Optimization**: Enjoy the performance benefits!\n\n## \ud83e\udd14 FAQs\n\n<details>\n<summary>Is it compatible with all Django versions?</summary>\nDjango-Cythonizer supports Django 3.2 and above, as specified in the project requirements.\n</details>\n\n<details>\n<summary>Will it break my existing code?</summary>\nNo, Django-Cythonizer is designed to be non-intrusive. Your original Python files remain untouched.\n</details>\n\n<details>\n<summary>Can I use it in production?</summary>\nAbsolutely! Many projects use Cython in production to great effect. Always thoroughly test before deploying.\n</details>\n\n## \ud83e\udd1d Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for more details.\n\n## \ud83d\udcdc License\n\nDjango-Cythonizer is released under the MIT License. See the [LICENSE](LICENSE) file for more details.\n\n## \ud83d\ude4f Acknowledgements\n\n- The amazing Django community\n- The Cython team for their incredible work\n- All our contributors and users\n\n## \ud83d\udcec Contact\n\nFor support or queries, reach out to us at [contact@salahaldain.com](mailto:contact@salahaldain.com).\n\n\n---\n<br>\n<p align=\"center\">\n  Made with \u2764\ufe0f by developers, for developers.<br>\n  Initiated by <a href=\"https://github.com/salah-alhajj\">Salah Aldain Alhajj</a>\n</p>\n\n",
    "bugtrack_url": null,
    "license": "MIT License with Usage Disclosure  Copyright (c) 2024 Salah Aldain Alhajj  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  2. Users of this Software must disclose the use of django-cythonizer in their project documentation or in a file named THIRD-PARTY-NOTICES (or similar) that accompanies the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A Django package for Cythonizing Django projects",
    "version": "0.0.12",
    "project_urls": {
        "Bug Tracker": "https://github.com/salah-alhajj/django-cythonizer/issues",
        "Homepage": "https://github.com/salah-alhajj/django-cythonizer",
        "Repository": "https://github.com/salah-alhajj/django-cythonizer.git"
    },
    "split_keywords": [
        "django",
        " cython",
        " optimization",
        " performance",
        " compilation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "87384bb097f37410840ac84a3fed16026557e846430190fd335139689e6a90d2",
                "md5": "93f3e4bf6f1345b42615c8ed7363d934",
                "sha256": "6e5060397c37b2e194066849a3d01487f0bd4f60eecd3b14c37e50e1131e20e1"
            },
            "downloads": -1,
            "filename": "django_cythonizer-0.0.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "93f3e4bf6f1345b42615c8ed7363d934",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 12660,
            "upload_time": "2024-07-19T15:33:31",
            "upload_time_iso_8601": "2024-07-19T15:33:31.079134Z",
            "url": "https://files.pythonhosted.org/packages/87/38/4bb097f37410840ac84a3fed16026557e846430190fd335139689e6a90d2/django_cythonizer-0.0.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5224536dedfe361c23bed8f6e6e6c945e387d406b25f25aa1adcafcec80b4f8b",
                "md5": "8920ef8f262cd8a3a8cd017a84a73e67",
                "sha256": "db75a0e4964ec239959c4fb66556b761e65f317fc28d25eeefad0432b912b8bc"
            },
            "downloads": -1,
            "filename": "django_cythonizer-0.0.12.tar.gz",
            "has_sig": false,
            "md5_digest": "8920ef8f262cd8a3a8cd017a84a73e67",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 13500,
            "upload_time": "2024-07-19T15:33:32",
            "upload_time_iso_8601": "2024-07-19T15:33:32.299042Z",
            "url": "https://files.pythonhosted.org/packages/52/24/536dedfe361c23bed8f6e6e6c945e387d406b25f25aa1adcafcec80b4f8b/django_cythonizer-0.0.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-19 15:33:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "salah-alhajj",
    "github_project": "django-cythonizer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "Cython",
            "specs": [
                [
                    ">=",
                    "3.0.10"
                ]
            ]
        },
        {
            "name": "Django",
            "specs": [
                [
                    ">=",
                    "4.2.13"
                ]
            ]
        },
        {
            "name": "djangorestframework",
            "specs": [
                [
                    ">=",
                    "3.15.2"
                ]
            ]
        },
        {
            "name": "PyYAML",
            "specs": [
                [
                    ">=",
                    "6.0.1"
                ]
            ]
        }
    ],
    "lcname": "django-cythonizer"
}
        
Elapsed time: 0.60480s