Многие из тех кто активно работал с 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
@redfoxuz / #rebranding#restyling
Facebook o'zini aydentikasini yangiladi
Xabaringizbo'lsa 3-4 kun oldin facebook logosi yangilangani haqida xabarlar bo'lganedi, endi esa aydentikasi ham yangilandi
Batafsil: https://design.facebook.com/stories/redefining-facebooks-brand-identity/
@redfoxuz / #rebranding#restyling
Instagram o'z brendini restayling qildi!
Yangi shrift, gradient rangi yanada yorqinlashgan. Yangi shriftdan tashqari "wordmark" va dastur ikonkasi yangilangan
Batafsil: https://about.instagram.com/brand
Restayling haqida qanday fikrdasiz?
📰 New Mercedes-Benz G-Class has received a retroversion
A total of 460 of these SUVs will be produced.
💪 The Mercedes G-Class 2025 lineup features an exclusive Stronger than the 1980s version inspired by the early Gelendwagen models.
🔎 The exterior differs due to black bumpers, underbody protection, orange turn signals, wheel rims and roof rack. The body colors are borrowed from the models of the 80s. The interior combines expensive Nappa leather and checkered fabric, and on the front panel there is a plate with the serial number and the inscription Stronger than the 1980s.
🐎 The models are offered with 3.0-liter turbo engines: G500 – 449 hp, G450 d – 367 hp.
💰 The price starts from $203,000.
@CarsNews
#Mercedes#restyling
🚘 has unveiled a Phantom Goldfinger car with a hidden gold bar in the cabin
🎂 The sedan was created for the 60th anniversary of Goldfinger – a film about James Bond. In the film, a millionaire criminal smuggles gold. He smelts gold and makes it into parts for his Rolls-Royce Phantom.
🔎 The modern Phantom received a golden-black body paint, repeating the colour scheme of the car from the film, and many other references to the film. For example, the signature nose piece ‘Spirit of Ecstasy’ looks as if it was made of pure gold, which for disguise was covered with silver, partially erased. In fact, the opposite is true: the mascot was made of silver and plated with an uneven coating of 18-carat gold.
@CarsNews
#RollsRoyce#Bespoke#restyling