@QuietWorld · Post #6814 · 29.10.2019 г., 06:30
Correction does much, but encouragement does more. #kindness@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
Пребарај: #kindness
@QuietWorld · Post #6814 · 29.10.2019 г., 06:30
Correction does much, but encouragement does more. #kindness@quietworld🍃
Hashtags
@QuietWorld · Post #6808 · 28.10.2019 г., 06:30
He who helps early helps twice. #kindness#life @quietworld🍃
@learnRCRussian · Post #5825 · 13.12.2025 г., 15:00
Служба спасения сов! Owl Rescue Service! 🦉Our fighters are rescuing an owl that got tangled in the fiber-optic cable from an FPV drone. • Сова (совы) (femin.noun) [sa-va (so-vy)] An owl(s) #news #kindness 😎RCR | Support | Boost
@learnRCRussian · Post #5821 · 12.12.2025 г., 13:00
Sometimes the world seems very difficult and complicated, doesn't it? 😽It is so difficult to remain kind and humane in our time, the harder our life is, the more pleased we are with videos where people support and understand each other, where a kind joke warms our hearts and makes our world brighter! 😽Yes, we are busy with our own affairs, burdened with problems, family events. We forget about the power of human kindness. A young girl, on her first day at work, is very worried. Every plate feels like a test, every look from the customer feels like a judgment. But instead of impatience, she is greeted with smiles. Instead of irritation, there are encouraging shouts and friendly hugs. The guests, as if sensing her vulnerability, choose sympathy. They thank and cheer her up. 😽This is a deep truth. Our strength is not in perfection, but in kindness. We offer kindness to others and choose it in ourselves. Video: Новый мир #kindness #brief_and_interesting #Russian_culture 😎RCR | Support | Boost
@QuietWorld · Post #7202 · 24.02.2020 г., 08:38
#life#love#kindness @quietworld🍃
@QuietWorld · Post #6779 · 23.10.2019 г., 23:30
🔖“What we have done for ourselves alone; dies with us. What we have done for others and the world; remains and is immortal.” · Albert Pike · #life#kindness#truth @quietworld🍃
@QuietWorld · Post #7625 · 07.10.2020 г., 02:01
#life#kindness#inspiration @quietworld🍃
Hashtags
@googlefactss · Post #40077 · 13.11.2025 г., 03:00
World Kindness Day, from the World Kindness Movement, is a universal awareness day about promoting the importance of being kind to each other, to yourself, and to the world, and is celebrated on the 13th of November every year. Celebrate by being kind online too. [Source] @googlefactss #Kindness#BeKind
@QuietWorld · Post #6748 · 19.10.2019 г., 13:00
Happiness is not so much in having as in sharing; We make a living by what we get, but we make a life by what we give. – Norman M. #kindness#happiness#life @quietworld🍃
Hashtags
@QuietWorld · Post #7764 · 24.03.2021 г., 22:24
#wisdom#kindness#truth @quietworld🍃
@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 #7694 · 24.11.2020 г., 00:54
#love#kindness#life#truth @quietworld🍃