Один из самых удобных способов записать данные это использование готовых форматов, такие как JSON или YAML.
Из плюсов такого подхода стоит отметить вот что:
🔸 готовый, повсеместно используемый и поддерживаемый формат
🔸 простой и понятный файл, удобочитаемый для человека
🔸 можно легко редактировать в любом текстовом редакторе без специальных программ и библиотек
Но есть и минусы
🔹 затраты времени при записи файла (кодирование данных в нужный формат строки)
🔹 затраты времени при чтении файла (декодирование данных в Python объекты)
🔹 размер файла увеличивается из-за разметки данных (скобки, запятые, переносы, отступы...)
🔹 перед записью все данные должны быть помещены в память в полном объёме (не всегда)
🔹 при чтении необходимо считать весь файл в память и только потом декодировать данные
Если нужно писать немного данных в несколько файлов, то затраты по времени не ощутимы. Обычно это файлы конфига или какие-либо метаданные. Это отличный вариант под такие задачи.
Есть и другой поход к записи файлов - это бинарные файлы. Используется, когда данных достаточно много и никто их не собирается читать глазками😳.
🔸 очень быстрая запись
🔸 чтение значительно быстрей чем JSON, YAML итд
🔸 размер файла значительно меньше, так как нет разметки
🔸 можно записывать данные по мере поступления не загружая всё в память
🔸 можно извлечь любую часть данных независимо
Из минусов
🔹 нужно определить свой формат записи данных (если не используете готовую спецификацию определённого формата)
🔹 не получится открыть файл и визуально понять что там записано, а для чтения файла потребуется знать его спецификацию.
🔹 не так-то просто создать такой файл без специальной библиотеки
В таком виде удобно записывать большой массив любых однородных данных. Например, мониторинг валютной биржи или кэшированная анимация 3D геометрии.
(Это не означает что нельзя записать данные разного типа, просто это будет не так удобно)
Представьте себе JPG-картинку. По сути это немного мета-информации и большой массив пикселей. Тоже самое со звуком или видео файлом. Поэтому, если вы попробуете открыть картинку в текстовом редакторе вы увидите что-то вроде такого
f15d cd29 a564 4578 ...
09e2 9bc4 a696 1253 ...
84e9 4de1 3b23 c24a ...
2534 5161 28e0 709d ...
...
Это и есть записанные байтики. И для их чтения требуется определённый софт который знает что с ними делать. Под каждый тип файла.
К чему это я? Читайте в следующем посте...
#tricks#basic
☺️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
🙏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