Skip to main content

A Django package for Cythonizing Django projects

Project description

Django-Cythonizer 🚀

Django-Cythonizer Logo

PyPI version Python Versions Django Versions License: MIT Build Status codecov

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

pip install django-cythonizer

Usage

  1. Add 'cythonizer' to your INSTALLED_APPS:
INSTALLED_APPS = [
    # ...
    'cythonizer',
    # ...
]
  1. Run the cythonize command:
python manage.py cythonize
  1. Open build FLoder and run it as normal django project

4. Enjoy the speed boost! 🎉🎉🎉🎉
## ⚠️ 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:

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

Is it compatible with all Django versions? Django-Cythonizer supports Django 3.2 and above, as specified in the project requirements.
Will it break my existing code? No, Django-Cythonizer is designed to be non-intrusive. Your original Python files remain untouched.
Can I use it in production? Absolutely! Many projects use Cython in production to great effect. Always thoroughly test before deploying.

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for more details.

📜 License

Django-Cythonizer is released under the MIT License. See the 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.



Made with ❤️ by developers, for developers.
Initiated by Salah Aldain Alhajj

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_cythonizer-0.0.12.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

django_cythonizer-0.0.12-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file django_cythonizer-0.0.12.tar.gz.

File metadata

  • Download URL: django_cythonizer-0.0.12.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for django_cythonizer-0.0.12.tar.gz
Algorithm Hash digest
SHA256 db75a0e4964ec239959c4fb66556b761e65f317fc28d25eeefad0432b912b8bc
MD5 8920ef8f262cd8a3a8cd017a84a73e67
BLAKE2b-256 5224536dedfe361c23bed8f6e6e6c945e387d406b25f25aa1adcafcec80b4f8b

See more details on using hashes here.

File details

Details for the file django_cythonizer-0.0.12-py3-none-any.whl.

File metadata

File hashes

Hashes for django_cythonizer-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 6e5060397c37b2e194066849a3d01487f0bd4f60eecd3b14c37e50e1131e20e1
MD5 93f3e4bf6f1345b42615c8ed7363d934
BLAKE2b-256 87384bb097f37410840ac84a3fed16026557e846430190fd335139689e6a90d2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page