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 слични објави

Пребарај: #baalbek

当前筛选 #baalbek清除筛选
Marwa Osman/MidEaStream

@marwa_osmanlb · Post #5037 · 23.10.2025 г., 12:13

While Zionist warplanes rained terror over #Baalbek Lebanon, our children stood tall, not crying, not running, rather shouting from their classrooms: "We shall never be humiliated." This is the spirit they cannot bomb. This is the generation they cannot break. From the heart of Baalbek, under the sound of explosions, rise voices louder than fear, echoing the promise that we will not kneel. To every child who stood firm today: you are the heartbeat of Lebanon, the voice of dignity, the living proof that resistance is not taught in books; it’s born in the blood of the free. هيهات منّا الذّلة✊🏻

Hashtags

Reuters: World

@reutersworldchannel · Post #149545 · 18.10.2021 г., 23:21

Lebanon's suffering Roman ruins Lebanon’s breath-taking Baalbek ruins – once a must-see attraction for thousands of visitors from around the world – lies almost entirely empty as the combined impact of the global health crisis and the country’s deep economic crisis hit the tourism sector. #tourism#Lebanon#News#Reuters#Baalbek Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3563 · 29.10.2024 г., 10:21

The Israeli warplanes launched more than 70 airstrikes against Lebanon’s densely-populated Beqaa, Baalbek and Hermel, massacring at least 63 people only on Monday. The Israeli strikes left many more injured and massive destruction across the area. #Beqaa#Baalbek#Hermel#LebanonUnderAttack#Israel

MessageInABottle

@mib_messageinabottle · Post #7111 · 22.11.2024 г., 13:32

To the #ZioNazi#genocidiares in #Israel, nothing is sacred. #Baalbek is an ancient #Phoenician city and is home to some of the world’s best-preserved #Roman ruins, such as the Temple of Bacchus. Baalbek was designated a #UNESCO World Heritage Site in 1984 for its ancient Roman temple complex. UNESCO describes these temples as “one of the finest examples of Imperial Roman architecture at its apogee” and they draw tourists from around the world. Tourism supports much of the local population, so naturally the ZioNazis have targetted some of its ancient buildings The older and more entrenched a building, a street, a monument, the more it is a target. Erasure and eradication. Displace and replace is the goal. The world went crazy for the Buddha statues in Bamiyan but remain mute for Baalbek.