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.10.tar.gz
.
File metadata
- Download URL: django_cythonizer-0.0.10.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 | 9e3a1e85f2e206c0d3a5030c51e381d963b47d460f8fd1a51588861a9b8457c5 |
|
MD5 | c535adc8de4b225883e3123b88e61cf3 |
|
BLAKE2b-256 | 6ff7f1076f2671ba50b44f64ca2abec9973f68b5bfb97af7f2a2137ec5ada52c |
File details
Details for the file django_cythonizer-0.0.10-py3-none-any.whl
.
File metadata
- Download URL: django_cythonizer-0.0.10-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 | b20ceb7766d27836fc1521f1b5e984871f1a4a39a05e52cbe5ab5d2eb4dcf3bd |
|
MD5 | bdeed3aece123be83b16e71ee715dffc |
|
BLAKE2b-256 | 4a09b821ce914f06878a172827b887b80e400ab4d66173f74a19d755c485294b |