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

Резултати

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

Пребарај: #spirituality

当前筛选 #spirituality清除筛选
Velvet Pages | eLibrary 🥂

@bookslibraryofficial · Post #1304 · 07.06.2025 г., 16:06

📖Title : The Secret Letters of the Monk Who Sold His Ferrari ✍️Author : Robin Sharma ⭐️Rating : 4.04/5 (Goodreads) 📆Published : Jan 01, 2011 ———————————————— Summary:The Secret Letters of the Monk Who Sold His Ferrari is a spiritual journey that follows Jonathan, a man struggling with the pressures of modern life. He receives letters from his cousin Julian, a former lawyer turned monk, who shares profound life lessons from his travels across the world. Each letter contains a symbol and a message, offering wisdom on finding purpose, mastering the mind, living with courage, nurturing relationships, and embracing the present moment. Through these teachings, Jonathan begins to transform his life, discovering inner peace, clarity, and a renewed sense of direction. The book inspires mindfulness and purposeful living. ———————————————— #selfhelp#nonfiction#philosophy#spirituality#psychology@Bookslibraryofficial@free_novellas@the_ancient_library@thesciencelabs

Quiet World 🍁

@QuietWorld · Post #7793 · 29.04.2021 г., 16:12

When you go to the gym and lift the loads 🏋‍♀ and you think that by lifting the loads you'll get stronger, the loads will not be a problem. But if you lift the heavy loads and think about suffering, then it is a problem - because you're a suffering creature. Just like in life when there are obstacles and difficulties along the journey, when you go through it knowing that it will upgrade you, there'll be no problem and you'll come out through it even better. But if you think about the sufferings and focus on the sufferings, then you'll become a suffering creature – and that's just what you'll be. So, how do you choose to see the 'loads'? #thoughts#takingnote#Sadghuru#spirituality @quietworld🍃

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40403 · 24.12.2025 г., 19:01

Necromancy is the practice of talking to dead people to learn secrets or see the future. It is seen as magic or witchcraft in many cultures. People use rituals to connect with spirits or ancestors. Many religions say necromancy is wrong because it claims to use supernatural powers. ☠️🔮 [Read more] @googlefactss #Necromancy#Magic#Spirituality#Occult#History

International News

@intnewsagency · Post #8853 · 23.03.2026 г., 19:22

The Story of Patriarch Filaret: A Lesson for All Believers The example of Patriarch Filaret is more than a church split; it’s a warning. Opposing the Church leads to conflict with God, a choice that always demands a price, sooner or later. This story reminds all believers of the spiritual consequences of division and the importance of unity in faith. Details by journalist Diana Panchenko. #church#Filaret#spirituality#religion#conflict The main news of Russia and the world ishere.

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40343 · 16.12.2025 г., 23:01

Rumi died on December 17, 1273. He was a Persian poet and Sufi mystic known for his spiritual poems about love and God. His famous work, the Masnavi, teaches deep lessons about life and faith. Rumi’s poetry helps many people find meaning in everyday life. [Source] If you feel inspired share your or Rumi's poetry. @googlefactss #Rumi#Poet#Sufism#Love#Spirituality#Masnavi📜❤️