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

Пребарај: #farmix

当前筛选 #farmix清除筛选

☺️Farmix – Latest News Review and Upcoming AMA Updates and changes: ➡️Increased RP for Lending in Farmix – in3⃣ The RP farm for providing liquidity in TON, USDT, NOT, stTON and tsTON, which can later be exchanged for protocol tokens, has been increased several times. ➡️ When closing a position, you can choose to convert LP into a credit token. At the moment, the function works in the $TON/$USDT pair and only for new positions. The update has fully prepared the team for the emergence of new highly liquid stablecoins with increased leverage up to 8x. ➡️Roadmap released ➡️ The formula for calculating the Estimate Profit indicator has been updated. ➡️ The #Farmix RP leaderboard in TMA has appeared. 🎙 The team announced an upcoming AMA session, where they will discuss the current results and plans of the project. The broadcast will take place on April 7 on the #Farmix Telegram channel at 19:00 UTC+3. You can ask questions through the form, and 3 participants with the most interesting questions will receive $USDT each. 📖 If you have any questions about the project, you can ask them in the chat. There is also a step-by-step text guide for opening a farm. Farmix | Channel | Documentation

Hashtags

🙏TON Society just added SBT Points For now not all SBTs have amount of points that their owners will receive, but a trend is already visible — the more valuable in terms of the number of points are #DeFi SBTs and for contributors to the blockchain. If you want to earn more points you have you should definitely get these SBTs: 💎 8 more days to get🙏9,500 for two valuable SBT Farmix in the BroBot contest✋ 💎12 days to get tBook SBT Late Night DeFi with general speed 🙏27,000 points. #TON#BroBot#SBT#Farmix

😎–Hey Bro! $1,500 and free SBTs for you! We’re launching a new quest with Farmix — leveraged lending liquidity protocol. Prize pool: just gain 600 XP and hold Lending for a chance to win one of 150 $10 prizes, extra XP, and guaranteed #SBT from TON Society! 🚀Join the quest now and share with your Bros! 📖 Deadline: Dec. 27, 15.00 UTC #TON#BroBot#contest#Farmix

🧑‍💻Review: Farmix – The Innovative Force in TON DeFi ☺️Farmix appeared relatively recently, it is a semi-finalist of #DoraHacks hackathon. In a nutshell, it is a marginal farming protocol that allows you to significantly increase the profitability of your farms by using leverage. 🪙 We have already tested their farming pools a couple of weeks ago, everything went well and without complications. At that time, the APR in the farms was very high, some pairs gave up to 9,000% APR. Below is a short guide for working with Farmix. 🐷 On average, #Farmix farms are 3-5 times higher than in #DEX pools. There are two options to earn income for providing your assets: Lending and Farms. We will look at the Farms option, because this is the most interesting: 🟡Log in to Farmix and connect your MTW wallet. 🟡 Go to the "Farmers" tab and find the pair you are interested in, for example we will use the STORM/TON pair. 🟡 First, select "Borrow asset" — this is the asset in which you will take a loan for leverage in the farm. In the case of the STORM/TON farm, only the TON loan asset is available. 🟡Enter in the $STORM/$TON fields how much STORM and TON you will provide as collateral. In #Farmix you can open a farm with one token, it is not necessary to provide both tokens, as the smart contract itself will convert the tokens into a 50/50 pair and form LP tokens. 🟡Select the leverage (Leverage slider) with which you want to open the farm. The higher the leverage, the higher the APR of the farm, but the liquidation risks also increase. 🟡Click Open position at the bottom, sign the transaction in the wallet and in a few minutes your first farm will be open. ⚠️Important: Please note that leverage is only provided for collateral in $TON , $USDT , $tsTON, $stTON, $NOT . Any position with leverage > 1 has its own health factor. HF > 1.3 is considered moderate, HF = 1 - the position is liquidated. 📊 At first glance, the guide may seem complicated, but everything is generally intuitive. If you have any questions about the work of the project, farms, etc., you can ask them 🔔in our chat. You will also receive RP points for staking and farming, more details in the "Reward activities" tab. And as usual #NFR#DYOR Farmix | Channel | Project documentation