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 слични објави

Пребарај: #lowvoltage

当前筛选 #lowvoltage清除筛选
CyberCharge Announcements

@cyberchargeannouncements · Post #27 · 27.08.2024 г., 16:02

🔋 "Low-voltage Transmission + DePIN" aims to optimize and enhance the performance and security of low-voltage systems by incorporating decentralized infrastructure. 🔌 Low-voltage transmission, which uses low voltage and small currents to transmit signals and data, combined with DePIN's decentralized features, enables safer, more reliable, and efficient data transmission. #CyberCharge will integrate hardware chargers using the Charge-to-Earn (C2E) model, allowing users to verify their identity while charging their devices, making data transmission more flexible and decentralized. #Lowvoltage#DePIN Like👍, Retweet🔵, Comment Link to the Tweet!

CyberCharge Announcements

@cyberchargeannouncements · Post #42 · 04.09.2024 г., 09:19

⚡️#CyberCharge: Innovations in Low-Voltage Transmission 🔌 Our charger not only meets everyday charging needs but also integrates seamlessly with custom modular components for storage and computing. These modular components are encrypted with our proprietary Cyber C1 AI chip, enhancing system security and reliability. #LowVoltage#AI#Charger Like👍, Retweet🔵, Comment Link to the Tweet!

Artel

@artelelectronics · Post #571 · 29.04.2022 г., 12:21

Elektr ta'minotining past bosimida ham texnikangizning uzluksiz ishlashini ta'minlaydi. __________________ Обеспечит бесперебойную работу вашей техники даже в условиях пониженной подачи электроэнергии. #Ishonchli#Barakali#Artel#Yangilik#Новинка#LowVoltage

CyberCharge Announcements

@cyberchargeannouncements · Post #38 · 03.09.2024 г., 07:44

🧐Did you know? "Low-voltage transmission" uses minimal voltage and small currents to safely transmit energy, commonly found in mobile devices and communication systems. 💡This principle is at the core of #CyberCharge, our innovative Web3 charger. 🔋By combining low-voltage technology with #DePIN and blockchain, we've created the world's first Charge-to-Earn (C2E) charger—secure, portable, and reliable. #Lowvoltage#Web3#charger Like👍, Retweet🔵, Comment Link to the Tweet!