@gifrumah · Post #8007 · 14.05.2026 г., 04:53
#SOOBIN
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
Пребарај: #soobin
@gifrumah · Post #8007 · 14.05.2026 г., 04:53
#SOOBIN
Hashtags
@bighitxtcom · Post #83724 · 12.05.2026 г., 14:21
[WEVERSE DM] | 260512 🐰: So cute #투모로우바이투게더#TOMORROW_X_TOGETHER#SOOBIN
@bighitxtcom · Post #83702 · 11.05.2026 г., 14:34
[WEVERSE DM] | 260511 🐰: You know dog owners like 🐰: Things like this more than that hahaha 🐰: My older brother sent me these pictures #투모로우바이투게더#TOMORROW_X_TOGETHER#SOOBIN
@bighitxtcom · Post #83699 · 11.05.2026 г., 14:34
[WEVERSE DM] | 260511 🐰: I’ll show you Tori who’s better looking too #투모로우바이투게더#TOMORROW_X_TOGETHER#SOOBIN
@bighitxtcom · Post #83698 · 11.05.2026 г., 14:33
[WEVERSE DM] | 260511 🐰: Ta-da #투모로우바이투게더#TOMORROW_X_TOGETHER#SOOBIN
@bighitxtcom · Post #83592 · 10.05.2026 г., 10:16
[WEVERSE DM] | 260510 🐰: Leaving nowww #투모로우바이투게더#TOMORROW_X_TOGETHER#SOOBIN
@bighitxtcom · Post #83588 · 09.05.2026 г., 15:06
[WEVERSE DM] | 260509 🐰: I used too many hair products today 🐰: So the hair stylist 🐰: Applied a product solvent on my hair and wrapped a towel around my head 🐰: I’m currently getting off work like this #투모로우바이투게더#TOMORROW_X_TOGETHER#SOOBIN
@bighitxtcom · Post #83324 · 04.05.2026 г., 14:32
[WEVERSE DM] | 260504 🐰: Hahahahahahaha I just came out for a walk 🐰: I was taking pictures so I could send them 🐰: And there was a grandpa on the other side going “oi oi!!” 🐰: The third picture is of me getting startled and looking at him 🐰: I went and was like “what happened?” 🐰: And he was like “why are you taking a picture of me!!” 🐰: So I went “I’m taking a selfie though”…and showed it to him 🐰: Then he tapped my shoulder and went 🐰: “What a handsome young man~” and left 🐰: Anyway I’m going to walk a bit today 🐰: I haven’t had the time to take a walk lately 🐰: So I’m just going to put my headphones on and walk around 🐰: While listening to music #투모로우바이투게더#TOMORROW_X_TOGETHER#SOOBIN
@bighitxtcom · Post #83306 · 03.05.2026 г., 15:26
[WEVERSE DM] | 260504 🐰: You’ve worked hard today too 🐰: It’s Monday 🐰: It’s the beginning of the week 🐰: Let’s get through this week strong too #투모로우바이투게더#TOMORROW_X_TOGETHER#SOOBIN
@bighitxtcom · Post #83199 · 01.05.2026 г., 14:20
[WEVERSE DM] | 260501 🐰: Mr. writer is currently getting his make up done 🐰: Oh omg 🐰: Hahahahahahah I wore the same t-shirt today that I’m wearing in the pictures above 🐰: I slept in today so I hurriedly put on the clothes that were on the floor 🐰: Oh well #투모로우바이투게더#TOMORROW_X_TOGETHER#SOOBIN
@bighitxtcom · Post #83197 · 01.05.2026 г., 14:20
[WEVERSE DM] | 260501 🐰: Write page.soobin came out with his new work 🐰: Pls quickly make sure to go read it #투모로우바이투게더#TOMORROW_X_TOGETHER#SOOBIN
@bighitxtcom · Post #82999 · 28.04.2026 г., 11:24
[WEVERSE DM] | 260428 🐰: Yoajung (= froyo brand) 🐰: (in konglish) get it. 🐰: What a great world 🐰: What do you mean there’s even low sugar ice cream? #투모로우바이투게더#TOMORROW_X_TOGETHER#SOOBIN