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

Резултати

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

Пребарај: #timcook

当前筛选 #timcook清除筛选

🅰️🩸🩸🩸🩸 📱Marketers criticize Apple for the fact that their copywriting has lost its brevity and former magic. The texts have become heavy, overloaded and unmemorable. Long-time fans of the company write that Steve Jobs would never have brought the company to such mediocrity. Tim Cook did not take courses in effective presentations 😮 What do you think about it? #Apple#Marketing#TimCook MARKHEMIST

🩸🩸🩸🩸🩸🩸1️⃣6️⃣ 📱iPhone 16 pre-orders have fallen short of Apple's expectations. The company sold 37 million smartphones in the first weekend, down 12% from last year. The iPhone 16 Pro is selling worse than the iPhone 15 Pro, but the base iPhone 16 is selling better than last year's model. Tim Cook: Where will you go when I release iOS 18 and ruin your batteries? 😄 😄 Have you already ordered new IPhone? #Iphone#Apple#TimCook MARKHEMIST

NEWS 鏈新聞-ABMedia

@abmedia_news · Post #24464 · 08.05.2026 г., 11:30

【📜 政策監理|川普邀輝達、蘋果、波音等企業執行長隨行訪中,川習會商機引發企業搶進】 #川習會#波音#TimCook 川普下週邀輝達與高通執行長訪中,由財政部長貝森特負責協調名單。 波音正爭取 500 架 737 MAX 等數百億美元訂單,庫克則處於關稅威脅下的抉擇兩難。即便商機龐大,官方仍強調峰會核心為政治關係而非具體商業協議。 📍閱讀全文: https://abmedia.io/trump-administration-plans-invite-tech-ceos 📍 訂閱鏈新聞頻道:https://linktr.ee/abmedia.io

Crypto M - Crypto News

@CryptoM · Post #64715 · 09.04.2026 г., 15:40

🚀 Apple Executives Sell $24.2 Million in Shares Amid Stock Decline Apple executives Tim Cook and Deirdre O'Brien have sold a total of $24.2 million worth of AAPL shares in April, according to SEC filings. Cook sold 64,949 shares for $16.5 million, while O'Brien sold 30,002 shares for $7.67 million. According to NS3.AI, Apple stock was trading at $258.90 and had declined nearly 4.5% year-to-date. #Apple#TimCook#DeirdreOBrien#AAPL#StockDecline#SECfilings#SharesSale#AppleStock