Многие из тех кто активно работал с Python2 несколько удивлены, почему в Python3 удобная функция reload() переехала из builtin в imp а потом и в importlib?
Ну было же удобно! А теперь лишний импорт😖
Дело в том, что начиная с Python3.3 функция reload() переписана на Python вместо Cи.
Что это нам даёт?
🔸 Такой код проще поддерживать и развивать
🔸 Python код легче читать, изучать и понимать.
Сравните это ➡️ и это ➡️.
🔸 Как результат пункта 2, проще писать свои расширения импорта. Например, пользовательский импортёр с какой-либо хитрой логикой по аналогии с импортом из zip архивов.
А есть ли у этого решения недостатки? Да, они всегда есть.
🔹 Так как это не builtin функция, её следует импортнуть перед использованием
🔹 Скорость замедлилась примерно на 5%. Очевидно, что это совершенно не критично. К тому же от версии к версии логика импорта будет оптимизироваться и ускоряться.
В самом начале файла importlib/__init__.py мы видим такой импорт:
import _imp # Just the builtin component, NOT the full Python module
То есть часть функционала по прежнему написана на Си, но достаточно низкоуровневая.
#basic
🚗✨ Introducing the stunning Pagani Utopia Roadster! 🌟
This masterpiece trades its traditional roof for a removable panel featuring a sleek glass insert. 🪟 For those who prefer a classic touch, there’s an alternative fabric top that neatly stores in its own case. 🎒
With no need for extra reinforcement, the Utopia's inherent strength shines through in this exquisite design. 💪
Under the hood, this beauty packs a powerful punch with an 864-hp V12 engine from Mercedes-AMG! 🔥💨
Get ready to own this automotive marvel for a cool €3.1 million! 💰
#PaganiUtopia#Roadster#Supercar#Auto#CarEnthusiast#DreamCar#ExoticCars#Pagani
🚙✨For Sale: Brabus 900 XLP!✨🚙
Get ready to own a masterpiece! This exclusive pickup, built on the Mercedes-AMG G 63 platform, boasts a staggering 900 horsepower and only 10 units produced! 🚀
📍Mileage: 3,375 km
💰Price: Nearly $1 million
Under the hood, it features a custom-built engine based on the stock V8, with an increased displacement of 4.5 liters, custom turbocharging, and upgraded components for unmatched performance! 🔥
#Brabus900XLP#LuxuryCars#ForSale#SuperPickup#CarEnthusiast#ExoticCars#MercedesAMG#DreamCar#Auto
🚗💨Unleash the Beast: 1600 HP Lamborghini Aventador SVJ!🦙🔥
For those who crave power and performance, Underground Racing Motors is offering a jaw-dropping 1600-horsepower Lamborghini Aventador SVJ for just $1.7 million!💰✨
Originally launched over six years ago, the Aventador SVJ boasts a naturally aspirated 6.5L V12 engine producing 770 HP and 720 Nm of torque. But with the magic of twin-turbocharging and expert tuning, this beast can roar up to an astonishing 1600 HP when fueled with race gas! 🏁💥 On regular gasoline, it still impresses with 1250 HP!
#Lamborghini#AventadorSVJ#UndergroundRacing#Supercar#CarEnthusiast#LuxuryCars#TurboPower#Hypercar#DreamCar#Auto
🚗✨For Sale: Aston Martin Vanquish!✨🚗
This stunning grand tourer isn't just any car; it was featured in a promotional photoshoot for the James Bond film "Die Another Day" starring Pierce Brosnan! 🌟
🔹Power: 460 HP
🔹Mileage: Over 60,000 km
🔹Price: Up to $100,000
Don't miss your chance to own a piece of cinematic history! 🎬💎
#AstonMartin#Vanquish#JamesBond#DieAnotherDay#LuxuryCars#CarForSale#BondCar#DreamCar#Auto
🏎 Get your hands on a piece of history! 🌟
Rare Lamborghini Countach LP400 up for auction! Previously owned by musician Rod Stewart.
Only around 150 LP400 Countach models were ever produced by Lamborghini, featuring a 3.9-liter V12 engine with 370 horsepower. Rod Stewart was the proud first owner of this incredible car, purchasing it in Australia during his tours and then bringing it back to the UK.
💲 Price: $520,000 💲
⏳ Only one day left until the end of the auction! ⏳
#Lamborghini#Countach#LP400#RodStewart#RareCar#MusicianOwned#Auction#DreamCar#MuscleCar#Legendary#CollectorCar