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

Резултати

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

Пребарај: #tehran

当前筛选 #tehran清除筛选
TƏBRİZ-TURAN-TV𒀭 (TTTv)

@tebriz_turan · Post #96004 · 29.03.2026 г., 18:02

❗️❗️#Tehran Şimali-şərq ərazisində, 9 Farvardin (29 mart) səhər saat 09:00 radələrində baş verən hücumlara aid vətəndaşlardan alınmış görüntülər sosial şəbəkələrdə paylaşılıb. Bizi teleqramda izləyin: https://t.me/tebriz_turan

Hashtags

TƏBRİZ-TURAN-TV𒀭 (TTTv)

@tebriz_turan · Post #96003 · 29.03.2026 г., 18:01

❗️❗️#Tehran Paytaxt şəhərində, Babayi avtomagistralı və Niru-ye Zamini bulvarı (Ləvizan ərazisi) yaxınlığında partlayışdan sonra tüstü qalxdığı bildirilir. Sosial şəbəkələrdə yayılan vətəndaş videosunda hadisənin bu gün səhər saat 09:00 radələrində baş verdiyi qeyd olunur. Bizi teleqramda izləyin: https://t.me/tebriz_turan

Hashtags

TƏBRİZ-TURAN-TV𒀭 (TTTv)

@tebriz_turan · Post #95994 · 29.03.2026 г., 17:47

❗️❗️#Tehran İranın paytaxtı şəhərində, Hərəvı meydanı yaxınlığında yerləşən binaya hücum edildiyi bildirilir. Qətərin telekanalı xəbər verir ki, hücum onların Tehran ofisinin yerləşdiyi binaya edilib. Məlumata görə, raket pilotsuz uçuş aparatından buraxılıb və canlı yayım zamanı binaya düşüb. Hadisə nəticəsində telekanal əməkdaşlarının xəsarət almadığı bildirilsə də, yaxınlıqdakı binalarda azı 10 nəfərin yaralandığı qeyd olunur. Hadisə ilə bağlı görüntülərin sosial şəbəkələrdə yayıldığı bildirilir. Bizi teleqramda izləyin: https://t.me/tebriz_turan

Hashtags

Addis Standard

@addisstandardeng · Post #21040 · 12.01.2026 г., 05:53

Deaths from #Iran protests reach more than 500, rights group says Unrest in Iran has killed more than 500 people, a rights group said on Sunday, as #Tehran threatened to target U.S. military bases if President Donald Trump carries out his renewed threats to intervene on behalf of protesters. With the Islamic Republic's clerical establishment facing the biggest demonstrations since 2022, Trump has repeatedly threatened to get involved if force is used on protesters. According to its latest figures - from activists inside and outside Iran - U.S.-based rights group HRANA said it had verified the deaths of 490 protesters and 48 security personnel, with more than 10,600 people arrested in two weeks of unrest. Iran has not given an official toll and Reuters was unable to independently verify the tallies. Trump was to meet with senior advisers on Tuesday to discuss options for Iran, a U.S..... https://www.reuters.com/business/media-telecom/confronting-protests-iran-vows-strike-back-if-us-attacks-2026-01-11/

Hashtags

Addis Standard

@addisstandardeng · Post #21556 · 28.02.2026 г., 07:23

#Israel launches “pre-emptive” strike on #Iran as explosions reported in #Tehran Israel said it launched a “pre-emptive” military strike on Iran early Saturday, with Iranian state media reporting explosions in parts of Tehran. Israeli Defence Minister Israel Katz said the operation targeted Iran and announced a nationwide state of emergency in Israel, citing the risk of retaliatory attacks. “Following a situational assessment, it was determined that as of today (Saturday), at 08:00, immediate changes will be made to the Home Front Command Guidelines As part of the changes, it was decided to shift all areas of the country from Full Activity to Essential Activity. The guidelines include: a prohibition on educational activities, gatherings, and workplaces, except for essential sectors,” IDF said in a statement posted on X (formerly Twitter). https://www.facebook.com/share/p/17brMhNLB3/?mibextid=wwXIfr

123•••10•••20•••2324
ПретходнаСтраница 1 од 24Следна