TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #32 · 7 фев.

Скорее всего уже слышали, что складывать строки через + это плохая практика. Падение производительности, и всё такое. Без лишних слов, давайте измерять: from timeit import timeit def t1(): # складываем 10 строк через + из переменной t = 'text' for _ in range(1000): s = t + t + t + t + t + t + t + t + t def t2(): # склеиваем список строк через метод join arr = ['text'] * 10 for _ in range(1000): s = ''.join(arr) def t3(): # складываем через + но не из переменной а непосредственно инлайн объекты for _ in range(1000): s = 'text' + 'text' + 'text' + ... # всего 10 раз Теперь каждую строку склейки запустим по 10М раз >>> timeit(t1, number=10000) 0.21951690399964718 >>> timeit(t2, number=10000) 1.4978306379998685 >>> timeit(t3, number=10000) 0.2213820789993406 Хм, а нам говорили что через "+" это плохо и медленно ))) 😁 Тут стоит учитывать, что речь идёт о склейке множества длинных строк. Давайте изменим условия: def t4(): t = 'text'*100 for _ in range(1000): s = t + t + t + t + t + t + t + t + t def t5(): arr = ['text'*100] * 10 for _ in range(1000): s = ''.join(arr) def t6(): for _ in range(1000): s = 'text'*100 + 'text'*100 + ... # всего 10 раз >>> timeit(t4, number=10000) 12.795130728000004 >>> timeit(t5, number=10000) 2.642637542999182 >>> timeit(t6, number=10000) 0.2184546610005782 Вот, уже другой разговор, сразу видна разница, в среднем в 6 раз. Но погодите, почему последний тест t6() по скорости такой же как и t3()? Ведь строки теперь в 100 раз длиннее! Это вопросы оптимизации кода, какие простые изменения ускоряют или замедляют выполнение программы. Мы столкнулись с примером обхода обращения к переменной. Например, именно так работает директива #define в С++, во время компиляции подставляя значение переменной вместо ссылки на неё. В Python это тоже работает, но часто ли вы сможете встретить такой способ работы со строками? К сожалению, способ почти только теоретический. В целом, тесты показали то, что мы хотели. Делаем выводы самостоятельно. Полный листинг 🌍 #tricks

Резултати

Пронајдени 34 слични објави

Пребарај: #mammals

当前筛选 #mammals清除筛选
Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40926 · 14.04.2026 г., 12:07

A dolphin can make about 700 to 1000 clicking sounds per second. The clicks come from deep inside the dolphin’s head, underneath the blowhole. Scientists call this area the phonic lips or sometimes “monkey lips.” @googlefactss#mammals

Hashtags

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40940 · 17.04.2026 г., 06:24

There are two main groups of bats: larger, Old World, fruit-eating mega bats (Megachiroptera) and microbats (Microchiroptera). Megabats are also known as fruit bats or flying foxes and typically live in warm climates. They use their large eyes to find food in the dark and they tend to roost in trees rather than in caves, crevices, or old buildings. Microbats are generally much smaller and use echolocation to find insects. Microbats are typically found all over the world, including the U.S. Not all megabats are larger than microbats. @googlefactss#mammals#nowyouknow

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40248 · 04.12.2025 г., 07:02

A mother koala 🐨 will feed her baby her own feces known as pap. Baby koalas—or joeys—haven’t developed the intestinal bacteria 🦠 that help detoxify the highly poisonous eucalyptus leaves 🍃, which are a koala’s main diet. This process is crucial for their survival. ❤️ @googlefactss#animals#mammals

Interesting Planet 🌍

@interesting_planet_facts · Post #482 · 01.08.2025 г., 20:22

🌎 In the dense forests of Southeast Asia, the binturong uses its prehensile tail like a fifth limb—wrapping it around tree branches for balance and grip. This adaptation helps it nimbly move through the canopy and reach fruit high above the forest floor. ✨ #mammals⚡#adaptation⚡#rainforest 👉subscribe Interesting Planet

Interesting Planet 🌍

@interesting_planet_facts · Post #399 · 23.07.2025 г., 20:22

🌎 The silky anteater is the world’s smallest anteater, fitting in your hand! With dense golden fur and a prehensile tail, it climbs trees at night to slurp up ants, avoiding predators with its tiny size and camouflage. ✨ #mammals⚡#rainforest⚡#adaptation 👉subscribe Interesting Planet

Interesting Planet 🌍

@interesting_planet_facts · Post #547 · 12.08.2025 г., 16:22

🌎 In the remote forests of India, the Malabar giant squirrel can leap over 6 meters between trees. Its colorful fur blends red, purple, and orange tones, making it one of the world’s most striking mammals. ✨ #wildlife⚡#biodiversity⚡#mammals 👉subscribe Interesting Planet

Interesting Planet 🌍

@interesting_planet_facts · Post #456 · 29.07.2025 г., 13:22

🌎 In the icy landscapes of Greenland, musk oxen survive Arctic winters thanks to an incredibly dense undercoat called qiviut, which is eight times warmer than sheep’s wool. This soft fiber insulates these shaggy animals so well that snow won't melt on their backs, even in the harshest cold. ✨ #mammals⚡#adaptation⚡#arctic 👉subscribe Interesting Planet

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40837 · 21.03.2026 г., 05:57

There's an animal that smells like buttered popcorn. The binturong (Arctictis binturong), a Southeast Asian "bearcat," smells like buttered popcorn due to 2-acetyl-1-pyrroline (2-AP) in its urine, which it uses to mark territory. This chemical is the same aromatic compound produced when popcorn is popped. These arboreal, cat-like mammals are threatened by habitat loss. @googlefactss#animals#mammals#bizarre [read more....]

Interesting Planet 🌍

@interesting_planet_facts · Post #1318 · 26.02.2026 г., 22:11

🌎 Every year, saiga antelopes in Central Asia undertake one of the largest mammal migrations, moving up to 1,200 kilometers across Kazakhstan and Russia. These critically endangered animals travel in herds of thousands to reach seasonal grazing areas, helping their calves survive harsh winters. ✨ #wildlife⚡#migration⚡#mammals 👉subscribe Interesting Planet 👉more Channels ​

ПретходнаСтраница 1 од 3Следна