
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Equivalent of PHP Autoloader
No, there isn't a direct equivalent to PHP's autoloader in Python and you don't need one also. To be specific, PHP needs autoloaders for the following reasons -
- For each web request to start a fresh PHP process.
- To load all the code from scratch for every request.
- For optimization by loading classes only when required .
- To avoid loading unnecessary files which improves performance.
In contrast, Python doesn't require autoloaders as files are not reread every time, and if you import something its imported for lifetime of the app. If you were to implement an autoloader in Python, it would run only one time and not on each request like PHP.
So autoloaders in PHP potentially give you a benefit of skipping the cost of file loading where you don't need it. In Python, you just load stuff when the app starts and new requests do not need to load anything extra.
Advertisements