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

Резултати

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

Пребарај: #climatescience

当前筛选 #climatescience清除筛选
Les Flashs Météo 气象追踪

@chinaweatherinfomationupdate · Post #227339 · 18.05.2026 г., 15:38

Honored by Prof. Hiroshi Takahashi's generosity in sharing his AAS Review Paper on land-surface influences on Asian monsoon precipitation and recommending the full special issue. Grateful for such support in advancing #climatescience ! Explore his study: https://link.springer.com/article/10.1007/s00376-026-5209-3#AAS via @aasjournal.bsky.social - Adv. Atmos. Sci.

Les Flashs Météo 气象追踪

@chinaweatherinfomationupdate · Post #227338 · 18.05.2026 г., 15:27

At the Ocean-Monsoon Conference 2026, @agturnermonsoon.bsky.social of the University of Reading presented a striking visual: the same location in India, captured under drought and active monsoon conditions. Two extremes. One region. A powerful reminder of what is at stake. 🧵👇#AAS#Climatescience via @aasjournal.bsky.social - Adv. Atmos. Sci.

IELTS|Newspapers & Magazines|English

@emagzinewspars · Post #9628 · 26.11.2025 г., 12:32

#Scientific_American🇺🇸📕[PDF]⬇️ #December2025 #Monthly_Magazines For learning, for free(dom). @backupofmagazines NASA faces a stalled Mars sample-return mission as funding reshapes priorities in #TechPolicy, while a promising mRNA-based personalized cancer vaccine struggles amid shrinking research budgets in the U.S., underscoring a rising #HealthCrisis. Scientists also warn that deepfakes demand new “face-ownership” rights, adding momentum to global #AIRegulation. Fresh insights into black-hole limits and rare-earth formation expand our cosmic and geologic imagination, even as #ClimateScience pushes oil and gas giants to pivot toward plastics. New antidepressant treatments and studies on small daily joys highlight a parallel #MentalHealth shift across society.

IELTS|Newspapers & Magazines|English

@emagzinewspars · Post #9633 · 26.11.2025 г., 12:32

#The_National_Geographic🇺🇸📕[PDF]⬇️ #December2025 #Monthly_Magazines For learning, for free(dom). @backupofmagazines This issue captures a world in transition, from ancient engineering puzzles to the fragile future of memory. Stunning visuals highlight global migration, ecological risk and cultural resilience, while scientists push deeper into #ClimateScience and #Neuroscience. A precise Mesopotamian map surprises historians, and a tribute to Jane Goodall reflects on her transformative legacy in #WildlifeResearch. The “Pictures of the Year” series showcases unforgettable scenes shaped by conflict, migration and #GlobalCulture. As melting ice reveals prehistoric secrets, explorers race against time, reminding us how fragile our world is in the age of #EarthChange and #FutureTech.

IELTS|Newspapers & Magazines|English

@emagzinewspars · Post #9391 · 21.10.2025 г., 08:58

#The_Science🇺🇸📕[PDF]⬇️ 16 #October2025 #Weekly_Magazines For learning, for free(dom). @backupofmagazines This week’s Science dives deep into the frontiers of #Nanoscopy, visualizing neural circuits with stunning 3D precision. From Arctic #Permafrost preserving ancient RNA viruses to #Ant colonies evolving architectural immunity, the issue spans from the microscopic to the planetary. Groundbreaking work tracks #SeaLevel change over 4.5 million years and explores durable #Hydrogen production membranes and electric control in #2Dmaterials. The “#ColdStorage” feature warns of hidden viral archives in melting ice—a chilling insight into #ClimateScience and future pandemics. A visionary issue linking biology, chemistry, and global sustainability through the lens of innovation.