@Marwa_OsmanLB · Post #3723 · 26.11.2024 г., 13:44
Ring of Fire made by Israel in #Beirut a few minutes ago. This could be you and you'd STILL be silent.
Hashtags
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
Пребарај: #beirut
@Marwa_OsmanLB · Post #3723 · 26.11.2024 г., 13:44
Ring of Fire made by Israel in #Beirut a few minutes ago. This could be you and you'd STILL be silent.
Hashtags
@Marwa_OsmanLB · Post #3713 · 24.11.2024 г., 11:23
Hezbollah missiles falling on Tel Aviv at 1:00 pm in retaliation to the massacres committed against Lebanese civilians in the heart of the Lebanese capital #Beirut.
Hashtags
@Marwa_OsmanLB · Post #3698 · 23.11.2024 г., 02:35
Footage from the massacre committed by the Zionist enemy on a building on Fathalla Street in the heart of the capital #Beirut Packed..i mean PACKED with residents and displaced people.
Hashtags
@Marwa_OsmanLB · Post #3696 · 23.11.2024 г., 02:10
A massacre...Israel just commit a massacre in the heart of the capital #Beirut. Just NOW. Fathallah street, Basta, Beirut. 4:00 am.
Hashtags
@Marwa_OsmanLB · Post #3695 · 22.11.2024 г., 22:38
It’s past midnight in #Beirut, and our "shelter" homes in the capital trembled as if there were no tomorrow—courtesy of the terrorist entity, Israel. Location: Chiyah area, Beirut, Lebanon.
Hashtags
@Marwa_OsmanLB · Post #3652 · 17.11.2024 г., 07:12
Under the world’s complicit silence, Israel continues to flatten clearly residential areas in #Beirut’s southern suburbs. These aren’t military targets. They’re homes. Lives. Futures. This is no accident; it’s a calculated erasure, making sure families have nothing to return to, even if the war ends. This was at 8:00 am today.
Hashtags
@Marwa_OsmanLB · Post #3635 · 13.11.2024 г., 09:59
Zionist Israel again today targets civilians residential areas in Ghobeiry, southern suburbs of #Beirut Terrorism is the daily bread of Israel.
Hashtags
@Marwa_OsmanLB · Post #3601 · 09.11.2024 г., 07:42
Another night of terror unfolded in #Beirut as Lebanese civilians endured relentless attacks, targeted by vile Zionist tereorists wielding U.S.-made weapons.
Hashtags
@Marwa_OsmanLB · Post #3442 · 11.10.2024 г., 05:09
Qassem writes about saving this baby in last night's attack by Zionist Israel on the central #Beirut: "This child was lying right here, on the remaining piece of the ceiling. When I reached him, I couldn't believe he could still be alive. But when I saw his eyes looking up at me, and how he grabbed onto me, completely in shock, I didn't know what to feel. This child will grow up, and with him, so will the hatred for this savage entity."
Hashtags
@Marwa_OsmanLB · Post #3354 · 27.09.2024 г., 20:32
Terrorist Israel issued a warning to evacuate certain areas in #Beirut suburbs. Who will issue a warning for their illegal colonial settlers to RUN?
Hashtags
@Marwa_OsmanLB · Post #3352 · 27.09.2024 г., 16:41
The scene from the heart of the intense Zionist terrorist aggression on #Beirut's southern suburbs on Friday September 27, 2024.
Hashtags
@Marwa_OsmanLB · Post #3313 · 22.09.2024 г., 15:39
The death toll from the Zionist aggression on the southern suburbs of #Beirut has risen to 51, following the recovery of another martyr's body. Ten people are still missing as search and rescue operations continue. Toll provided on 6:30 pm Beirut local time.
Hashtags