Многие из тех кто активно работал с 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
📰US stock prices soar in early Asian trading after truce news
🔗https://top-news.shepherdgazette.com/us-stock-prices-soar-early-asian-trading-truce/?utm_source=telegram&utm_medium=social&utm_campaign=zimm-distribute
via Daily Political Press
#Asian#TopNews#News
News: #Ethiopia, #Asian Infrastructure Investment Bank discusse support for Bishoftu airport project
Ethiopia’s Minister of Finance, Ahmed Shide, has held discussions with the President of the Asian Infrastructure Investment Bank (#AIIB) on potential financing support for the planned #Bishoftu International Airport project.
According to a statement from the Ministry of Finance, the meeting focused on strengthening cooperation between Ethiopia and the multilateral lender, with particular emphasis on priority infrastructure and development initiatives.
The two sides also explored avenues to expand collaboration in mobilizing private sector financing.
A week ago Addis Standard reported that Ahmed Shide, Ethiopia’s Minister of Finance, held high-level discussions with a delegation from the #China Export-Import (Exim) Bank and the Chinese Ambassador to Ethiopia, Chen Hai, the talks centered on exploring financing options for the construction of the Bishoftu....
Read more: https://addisstandard.com/?p=56203