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

Резултати

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

Пребарај: #date

当前筛选 #date清除筛选
Viral Today

@Viral_Today · Post #1492 · 05.07.2021 г., 15:51

Mark Zuckerberk(creator of Facebook) posted a video of him celebrating 4th of July by surfing on an electronic waveboard with a US flag YouTubeNews/ #date

Hashtags

CREO UZBEK

@creo_uzbek · Post #30 · 01.10.2024 г., 04:02

#DATE Ustoz otangdan ulug‘ Fidoyilik bilan xizmat qilgan ustozlarga bo‘lgan cheksizhurmat-ehtirom dono xalqimizning og‘zaki ijodida o‘chmas iz qoldirgan. Farzandlarimizni tarbiyalashda, ong va tafakkurini rivojlantirishda, davlatimiz ravnaqi yo‘lidan borishga undashda ustozlarimizning hissasi beqiyos. Aziz o‘qituvchi va murabbiylar, Sizlarni kasb bayramingiz bilan tabriklaymiz. Bizga chuqur bilim berganingiz va tarbiyalaganingiz, yetuk mutaxassis bo‘lishimizga yordam berganingiz uchun cheksiz minnatdorchilik bildiramiz. Shaxsiy va professional hayotingizda yanada ko‘proq marralarga erishing! 📱Telegram📱 Instagram

Hashtags

Viral Today

@Viral_Today · Post #1971 · 05.04.2022 г., 13:59

Complete time-lapse of r/place 2022 Every user was given an option to add only one pixel to the canvas every 5 minutes, making it impossible for anyone to build it alone. This event lasted 4 days with millions of people participating YouTubeNews/ #wow#date

Hashtags

Viral Today

@Viral_Today · Post #1557 · 18.08.2021 г., 11:00

The Life-Size Toyota Supra GR Model Was Made With 477,000 Legos—and It Actually Runs The pixel-like sports car celebrates the 35th anniversary of the Toyota Supra. The Lego model spent 3,000 hours in development and underwent another 2,400 hours being built, according to Toyota Gazoo Racing. It weighs in at 4,156 pounds (1,885 kilograms) and is outfitted with an electric drivetrain that lets it take to the road. It can only reach a max speed of 17 mph (28 kph) YouTubeNews/ #interesting#date

Firefly waiting for date in an alternate universe Source by pixiv Harukix 原始标签:#HonkaiStarRail#流萤星穹铁道#崩坏星穹铁道#date#崩坏星穹铁道1000收藏 自定义标签:#甜妹#流萤#可爱 尺寸: 2122x3489 @CosineGallery | 网站 | 4281

Trump's Ear

@trumpsear_tg · Post #1541 · 21.09.2025 г., 13:59

In the United States, there's a growing theory 🌍 that Charlie Kirk 🎯 and George Floyd ⚖️ were born on the same day, exactly 20 years apart, which explains why they met similar fates. Astrologer John Townley 🌟 says Floyd and Kirk are "Mercurian brothers 👫 who couldn't avoid their tragic endings... They were both good people, but astrologically speaking, Floyd was like an angel testing us before Judgment Day." 🙏 #kirk#floyd#birth#date#mercurian 👂More on Trump's Ear ⚠️

QQ资源岛-破解软件分享

@QQZYDAPP · Post #4524 · 03.11.2025 г., 15:59

⭐️【资源名称】: Image & Video Date Fixer 图像视频日期修改 🤖【适用平台】: #Andoid 🔄【应用版本】: 2.40.5 🔩【应用大小】:14MB 🧱【资源介绍】 微商工具 Image & Video Date Fixer是一款可以将你的照片或视频进行日期修正,将日期恢复到你拍摄照片或视频的日期及时间!这种情况是当图片被移动或下载到设备上时,文件的修改日期会被更新为当前日期 🟢绿化版 🟡在线下载:点击下载(无需密码) 📁#安卓软件#Image#Video#Date#Fixer#图像视频#日期修改

Eva Karene Bartlett

@EvaKarene_Bartlett · Post #29131 · 29.12.2025 г., 07:33

📍#المكان: اللاذقية 🗓️#الزمان: ٢٨/١٢/٢٠٢٥ ⚠️#الحدث: مؤيدو سلطة الأمر الواقع الإرهابية شاركوا السلطة الإرهابية في قمع المتظاهرين السلميين باستخدام الأسلحة البيضاء، كما يظهر في الصور (صواطير وعصي). كانوا يسعون لإسكات صوت المطالبين بحقوقهم، لكن الحق لا يمكن كتمه مهما اشتدت المحاولات. #قمع_مظاهرات_سلمية #Location: Latakia 🗓️#Date: 28/12/2025 ⚠️#Incident: Supporters of the terrorist de facto authority participated with the terrorist authority in suppressing peaceful demonstrators using bladed weapons, as shown in the photos (axes and sticks). They sought to silence the voices of those demanding their rights, but the truth cannot be silenced, no matter how strong the attempts. #Suppression_of_Peaceful_Demonstrations 🌐 رابط القناة: [https://t.me/Syrdoc] 📩 للتبليغ عن الانتهاكات: [https://t.me/Syrdocbot]

12
ПретходнаСтраница 1 од 2Следна