Python 3.13 में JIT compiler जोड़ा गया
- CPython core developer Brandt Bucher ने Python 3.13 branch में JIT compiler जोड़ने के लिए एक pull request submit किया है.
- यह बदलाव, Python 3.11 में जोड़े गए specialized adaptive interpreter के बाद, CPython interpreter में सबसे बड़े बदलावों में से एक होगा.
JIT क्या है?
- JIT (Just in Time) compilation ऐसी design को संदर्भित करती है जिसमें code के पहली बार चलने पर compilation होता है.
- JIT compiler वह compiler होता है जो machine code बनाता है, और यह AOT (Ahead of Time) compiler के विपरीत है.
- Python code पहले bytecode में compile होता है, और यह bytecode CPU के लिए अपने-आप में अर्थहीन होता है तथा एक विशेष bytecode interpreter loop के जरिए execute होता है.
copy-and-patch JIT क्या है?
- copy-and-patch JIT 2021 में प्रस्तावित एक अवधारणा है, जिसे dynamic language runtime के लिए एक तेज algorithm के रूप में design किया गया था.
- copy-and-patch JIT का विचार यह है कि हर instruction के लिए निर्देशों को copy किया जाए और bytecode arguments को भरा जाए (patch किया जाए).
copy-and-patch JIT के फायदे और नुकसान
- जहाँ "पूर्ण" JIT compiler high-level bytecode को intermediate language (IL) के low-level instructions में compile करता है, वहीं copy-and-patch JIT bytecode से machine code में compilation को templates के एक set के जरिए करता है.
- copy-and-patch JIT में Python runtime के भीतर किसी जटिल JIT compiler architecture को चलाने की जरूरत नहीं होती, और केवल उस machine पर LLVM JIT tools install करने होते हैं जहाँ source से CPython compile किया जा रहा हो.
यह JIT कैसे काम करता है?
- Python 3.13 के API में नए जोड़े गए API का विस्तार किया गया है ताकि pluggable optimizers को runtime पर खोजा जा सके.
- नया JIT इस नई architecture के लिए एक optional optimizer है.
- source से CPython compile करते समय
--enable-experimental-jit flag देने पर Python bytecode के लिए machine code templates generate किए जाते हैं.
क्या यह JIT तेज है?
- शुरुआती benchmarks लगभग 2-9% performance improvement दिखाते हैं.
- यह JIT उन optimizations की एक श्रृंखला की आधारशिला है जो Python की performance को काफी बढ़ा सकती हैं.
GN⁺ की राय
- Python 3.13 में जोड़ा गया JIT compiler, Python की execution speed को बेहतर बनाने वाला एक महत्वपूर्ण बदलाव है, खासकर repetitive tasks के लिए इसकी efficiency बढ़ा सकता है.
- copy-and-patch JIT, उपयोगकर्ता के Python runtime में जटिल JIT architecture को integrate किए बिना performance सुधारने का एक अभिनव तरीका पेश करता है.
- यह तकनीक Python community के लिए दिलचस्प चर्चा का विषय बनेगी और उम्मीद है कि यह Python performance optimization के नए रास्ते खोलेगी.
1 टिप्पणियां
Hacker News राय