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

Резултати

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

Пребарај: #cursive

当前筛选 #cursive清除筛选
Learn RCRussian🤍💙❤️

@learnRCRussian · Post #5439 · 15.09.2025 г., 15:00

Почерк — это отражение нашей личности на бумаге. Handwriting is a reflection of our personality on paper. ✍️Николай Гоголь Nikolai Gogol ✍️Эрнест Хемингуэй Ernest Hemingway ✍️Александр Дюма (отец) Alexandre Dumas père ✍️Владимир Набоков Vladimir Nabokov ✍️Джейн Остин Jane Austen ✍️Александр Пушкин Alexander Pushkin ✍️Вирджиния Вулф Virginia Woolf ✍️Иоганн Гёте Johann Wolfgang von Goethe ✍️Франц Кафка Franz Kafka ✍️Лев Толстой Leo Tolstoy ❓️How is your handwriting when you write in Russian?😉 ▶️Russian cursive letters (+practice) #cursive #brief_and_interesting 😎RCR | Support | Boost

Learn RCRussian🤍💙❤️

@learnRCRussian · Post #5661 · 06.11.2025 г., 15:00

School in the Russian Empire, late 19th century ❓️Can you read the 3 words written on the board? 🗝 In the Russian Empire 'i' stood for modern 'и': 1. Жукъ = жук (beetle) 2. Ученiя = учения (studies) 3. Сiянiе = сияние (shining) ▶️Reforms in 1918 #retrophotos #cursive 😎RCR | Support | Boost

Learn RCRussian🤍💙❤️

@learnrcrussian · Post #5112 · 17.07.2025 г., 15:07

In Russia doctors may be required to print prescriptions: many pharmacists and patients struggle to read their handwriting. 🔻This leads to the refusal of medication sales, treatment delays, or the dispensing of the wrong drug, believes MP Anton Tkachev. He emphasized that it's especially difficult for the elderly, who cannot decipher the prescriptions themselves. 📎 And you say you can't read what Russians write. Russians themselves struggle to decipher what other Russians write! :) Source: rt_russian #cursive #learnRussian #news 😎RCR | Support | Boost

Learn RCRussian🤍💙❤️

@learnrcrussian · Post #4951 · 01.07.2025 г., 10:00

That merciless Russian cursive handwriting! • Шиш [shysh] 🔻This interjection (or sometimes exclamatory noun) is used to denote a strong, emphatic refusal, denial, or the idea of nothing or you won't get anything. ⚠️It's generally rude or dismissive! 🔻Шиш is a very close synonym of фиг. Both words are used in similar contexts to express negation, refusal, or to refer to the fig sign gesture. 🔻While фиг might be slightly more common and versatile in some everyday expressions, шиш carries a similar dismissive and negative connotation. #spoken_Russian #cursive #foul_language 😎RCR | Support | Boost

Learn RCRussian🤍💙❤️

@learnRCRussian · Post #5607 · 27.10.2025 г., 07:32

Writing Ч ч in cursive can be challenging, but not for you! 🔻Let's watch the video, print out the practice sheet and, shedding tears of despair, practice and move on. ❓Which other letters of the Russian alphabet make you overwhelmingly want to chuck the study of Russian overboard? 📎The pdf file is in the comments ▶️Hard sign tutorial ▶️Сursive letters #practice #cursive 😎RCR | Support | Boost

Learn RCRussian🤍💙❤️

@learnrcrussian · Post #4497 · 11.04.2025 г., 10:58

Writing the hard sign (ъ) in cursive can be challenging, but not for us, right? 🔻Let's watch the video, print out the practice sheet and, shedding tears of despair, practise and move on. ❓Which other letters of the Russian alphabet make you overwhelmingly want to chuck the study of Russian overboard? 📎 file is in the comments ▶️Сursive letters #practice #cursive 😎 Stay with @learnRCRussian

Learn RCRussian🤍💙❤️

@learnRCRussian · Post #5464 · 21.09.2025 г., 18:37

Напиток называется "Grappa", а не то что вы прочитали. The drink is called Grappa, not what you read. 🤔What did you read? 🗝 🔞⚠️ • Су‌чара (femin.) [su-cha-ra] ⚠️ Vulgar slang! A highly offensive, intensified version of сука(bitch). Means something like a total bitch. Expresses extreme hatred, betrayal, or disgust. ❗️Do not use this word! Understand it only to recognize aggression in speech or media! #cursive #linguistic_joke #Russian_riddle #foul_language 😎RCR | Support | Boost