@QuietWorld · Post #7102 · 24.12.2019 г., 01:35
🗾 How often we fail to realize our good fortune in living in a country where happiness is more than a lack of tragedy. #quotes#gratitude @quietworld🍃
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
Пребарај: #gratitude
@QuietWorld · Post #7102 · 24.12.2019 г., 01:35
🗾 How often we fail to realize our good fortune in living in a country where happiness is more than a lack of tragedy. #quotes#gratitude @quietworld🍃
Hashtags
@QuietWorld · Post #6773 · 23.10.2019 г., 08:30
🔖 Appreciate where you are in your journey, even if it's not where you want to be; every season serves a purpose. #life#gratitude#wisdom @quietworld🍃
Hashtags
@QuietWorld · Post #6625 · 02.10.2019 г., 03:52
"How cool is it that the same God who created mountains and oceans and galaxies looked at you & thought, the world needed one of you, too." #quotes#reminder#gratitude @quietworld🍃
Hashtags
@QuietWorld · Post #6904 · 14.11.2019 г., 14:55
#positivity#gratitude @quietworld🍃
Hashtags
@QuietWorld · Post #6811 · 28.10.2019 г., 13:01
We love those people who give with humility, or who accept with ease. #kindness#gratitude @quietworld🍃
Hashtags
@QuietWorld · Post #7145 · 14.01.2020 г., 00:32
Life is Simple First, Don't bother with other people's lives, no need to comment much, no slander here and there, no need to make fun of it.. Second, Live within your means. Don't torture yourself just to follow trends or impress people. Third, Just enjoy your life and be the best you can be. Be grateful for what you have, and do what you want. Fourth, Don't listen to what people say. Even if that person insults you. Just remember, you didn't ask that person to feed you anyway. Have a blessed day ☺️🌻 #life#gratitude#attitude @quietworld🍃
Hashtags
@the_life_tips · Post #16090 · 11.05.2025 г., 04:30
Happy Mother's Day!🤰🤱🎉 Today, we celebrate the strength, wisdom, and unconditional love of all mothers. A mother is not just someone who gives life, but someone who inspires it. She teaches us resilience through her sacrifices, courage through her actions, and love without limits. Take a moment to appreciate the woman who shaped your beginnings. And if you're striving for greatness—remember, behind every strong person is often a mother who believed in them first. Honor her. Thank her. Make her proud. #MothersDay#Gratitude LIFE TIPS✅️
Hashtags
@news_and_tips · Post #825 · 21.01.2023 г., 02:30
Hello 👋 everyone! Today is my birthday🍰 and I just wanted to take a moment to thank each and every one of you 🫵 for being a part of my journey. Your support and encouragement means the world to me❣. I'm excited to continue creating content and sharing it with you all. Here's to another year of growth and adventure! Cheers! 🥂 #birthday#gratitude
Hashtags
@QuietWorld · Post #6821 · 30.10.2019 г., 06:30
"I don't have to chase extraordinary moments to have happiness – it's right in front of me if I'm paying attention & practicing gratitude." #happiness#gratitude#reminder @quietworld🍃
Hashtags
@QuietWorld · Post #7696 · 25.11.2020 г., 00:45
Simple Pleasures in Life #life#gratitude#beauty @quietworld🍃
Hashtags
@QuietWorld · Post #7181 · 04.02.2020 г., 07:41
when life gets hard, count your blessings.. it might not solve all your problems, but it'll help you go through the hard times easier and better..🍃 #afterthoughts#thoughts#gratitude#attitude @quietworld🍃
@QuietWorld · Post #6856 · 04.11.2019 г., 13:33
Appreciate where you are in your journey, even if it's not where you want to be - because every season serves a purpose. #life#quotes#assurance#gratitude#happiness @quietworld🍃