A Django package for Cythonizing Django projects
Project description
Django-Cythonizer 🚀
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
- Add 'cythonizer' to your INSTALLED_APPS:
INSTALLED_APPS = [
# ...
'cythonizer',
# ...
]
- Run the cythonize command:
python manage.py cythonize
- 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
andurls.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
- Analysis: Django-Cythonizer scans your project structure.
- Compilation: It compiles eligible Python files to Cython.
- Integration: The compiled modules seamlessly replace the original ones.
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | db75a0e4964ec239959c4fb66556b761e65f317fc28d25eeefad0432b912b8bc |
|
MD5 | 8920ef8f262cd8a3a8cd017a84a73e67 |
|
BLAKE2b-256 | 5224536dedfe361c23bed8f6e6e6c945e387d406b25f25aa1adcafcec80b4f8b |
File details
Details for the file django_cythonizer-0.0.12-py3-none-any.whl
.
File metadata
- Download URL: django_cythonizer-0.0.12-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e5060397c37b2e194066849a3d01487f0bd4f60eecd3b14c37e50e1131e20e1 |
|
MD5 | 93f3e4bf6f1345b42615c8ed7363d934 |
|
BLAKE2b-256 | 87384bb097f37410840ac84a3fed16026557e846430190fd335139689e6a90d2 |