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

Резултати

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

Пребарај: #memoir

当前筛选 #memoir清除筛选
Pensive|

@PensivePost · Post #4932 · 14.02.2021 г., 13:53

My First Encounter With Death-: I was then a Puerilo of Around 6 & Studied in U.K.G or Perhaps L.K.G, I used to go to School on Foot. On My Way to School and Back To Home , I did See an Old Man He was a Hindu & Perhaps A Brahmin Sitting on a Khatola Out his House Looking me He did Send a Smile And this Scene was not a Talk of Someday ,A Year Passed that way Never I gone near Him ,Neither I ever Sent him That Smile Back He was After all a Stranger A REGULAR STRANGER Then a Day On My Way Back Home , I Saw Crowd Out his House He was Made Sleep on Ground And was Draped with White Cloth Then A Moment Next People Lifted him up on Some Woody-Arrangement & Started Saying ‘’RAAM NAAM SATYA HAI ...... RAAM NAAM SATYA HAI......’’ I Understood Nothing Yet I get Blank , My Neck Got Dried , My Blood Felt-like Freezed, My Body Stiffened , I was Suffocating A Horror and Pain Sticken To My Heart & I Started Crying to My Fullest on my way Even Some People of My Dada-Abbu’s Pehchaan stopped & Asked me ‘’ Kaa Hua Babua Kahen Rovat Hey ‘’ But I just Cried I reached Home My Daadi , My Phupphi , My Ammi & My Par-Daadi all tried to Stop me from Sobbing but i myself was not having Control over it , it was Coming itself I Cried and just Cried till i got into Grip of Sleep I Caught High Fever , loose-Motions , Vomitting and just wht not I had not Gone School For 5-6 Days . When I resumed my Schooling then on that way No More a Person In Vest & Dhoti With a Smile to Greet Sits On Khatola Out There On That ‘Chabotra’ [A Raised Land] I did Send Smile Back Daily Paying The Debt I Owe to Someone But None To Receive....... #review #Memoir #The_Robinhood

Tashkent students in the 1950s and my memories of working in the cotton fields in 1979–1981. A firsthand look at Soviet cotton campaigns in Uzbekistan and their lasting impact. https://yep.uz/en/2025/10/cotton-harvesting-uzbekistan-1980s-memories-1950s-photos/ #uzbekistan#cottonharvest#sovietera#tashkent#memoir#students

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40836 · 20.03.2026 г., 23:10

Part 2: Babur, at age 13, wrote in the Baburnama about his feelings for a boy named Baburi: > “In those leisurely days, I discovered in myself a strange inclination — nay! as the verse says, ‘I maddened and afflicted myself’ — for a boy in the camp‑bazar, his very name, Bāburī, fitting in. Up till then I had had no inclination for anyone… From time to time Bāburi came to my presence but out of modesty I could never look straight at him… I got so confused that I almost went right off.” 💌📖👑 Note: this does not mean he was homosexual. Such feelings can be a normal part of teenage self-discovery. @googlefactss #Baburnama#Babur#MughalHistory#HistoricalFacts#LoveInHistory#Memoir#HonestWriting

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40835 · 20.03.2026 г., 23:01

Part 1: Babur, the Mughal emperor and a Muslim, wrote the Baburnama, a detailed personal memoir. In it, he shared his feelings openly. He wrote about his love and admiration for women. He also felt strong affection and admiration for a boy named Baburi. He described these emotions with honesty and detail. He sometimes wrote poems about his feelings. His writing shows both his emotional sensitivity and his poetic talent. He mixed personal experiences, romantic feelings, and reflections on life. Babur’s memoir is considered important for both history and literature. It gives a rare glimpse into his private thoughts, he was not afraid to show his personal desires and emotions. Both his relationships with women and his emotional attachment to Baburi are part of the memoir. His writing style is clear, candid, and expressive. The writings are valued for its literary quality and honesty. 💌📖👑🕌 [Read more1] [Read more2] @googlefactss #Baburnama#Babur#MughalHistory#HistoricalFacts#LoveInHistory#Memoir#Islam