Многие из тех кто активно работал с 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
🪐 Just 12 light-years away, the red dwarf star Teegarden’s Star hosts two Earth-sized exoplanets, Teegarden’s Star b and c, both located in the star’s habitable zone. This zone is the area around a star where temperatures could allow liquid water to exist—a key ingredient for life as we know it—making these planets some of the most intriguing nearby candidates in the search for life beyond our solar system. ✨
#exoplanets⚡#habitablezone⚡#astrobiology⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The exoplanet K2-18b, located about 120 light-years away in the constellation Leo, has been found to possess water vapor in its atmosphere—making it one of the few known exoplanets within its star’s habitable zone where conditions might allow liquid water. K2-18b is a "mini-Neptune," meaning it’s larger than Earth but smaller than Neptune, and its potential for moderate temperatures and watery clouds raises the possibility that life-friendly environments could exist beyond our solar system. ✨
#exoplanets⚡#life⚡#habitablezone⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Deep in the constellation Aquarius, astronomers have discovered exoplanet K2-72e orbiting a cool red dwarf star roughly 227 light-years from Earth. K2-72e is a rocky world located within its star’s habitable zone—the region where temperatures might allow liquid water on the surface—making it another intriguing candidate in the search for planets that could support life beyond our solar system. ✨
#exoplanets⚡#habitablezone⚡#discovery⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 Astronomers have identified Proxima Centauri b, an Earth-sized exoplanet orbiting the closest star to our Sun, as one of the nearest spots where life could possibly exist. Sitting in its star's "habitable zone"—the region where temperatures might allow liquid water—this world offers a natural laboratory to explore the potential for life beyond our solar system. ✨
#exoplanets⚡#habitablezone⚡#discovery⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The exoplanet TOI-700 d, orbiting a small, cool star about 101 light-years away in the constellation Dorado, lies within its star’s “habitable zone,” where temperatures might allow water to exist as a liquid on the surface. This rocky world is similar in size to Earth and is one of the few confirmed planets outside our solar system where scientists believe the conditions could be just right for life as we know it to survive. ✨
#exoplanets⚡#habitablezone⚡#dorado⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Over 42 light-years from Earth, the exoplanet Tau Ceti e orbits within the habitable zone of its Sun-like star—meaning it receives just the right amount of energy that could allow liquid water to exist on its surface. While Tau Ceti e is about 60% larger than Earth and its true environment remains a mystery, its location around one of our closest stellar neighbors makes it a real and intriguing candidate in the search for life beyond our solar system. ✨
#exoplanets⚡#habitablezone⚡#lifebeyondearth⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Astronomers have identified the exoplanet Wolf 1069 b, located about 31 light-years away in the constellation Cygnus, as a promising place where life could exist. This rocky planet orbits in its star's habitable zone—the region where temperatures may allow liquid water to pool on the surface—making it one of the most intriguing nearby candidates in the search for life beyond our solar system. ✨
#exoplanets⚡#habitablezone⚡#wolf1069b⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries