Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
🚨CyberCharge discount sale ends, price back to $198! 🚨
Thanks to all our supporters — nearly 10,000 devices shipped globally 🌎
More users are joining the Web3 journey of earning while charging ⚡️
CyberCharge is becoming the 1 choice for #DePIN earners.
🔥Follow us for occasional limited-time $148 promotions!
🤖Earn NOW📱X(Twitter) 📱Chat💬Discord📱YouTube
TWITTER SPACE!!
🕊
🚀 Join us on Aug 20th at 12 PM UTC for a Twitter Space on the #DePIN wave!
📚Topic: Can the Bitcoin ecosystem become the new battleground in the DePIN wave?
📍https://twitter.com/i/spaces/1DXxydzBZVNJM
👥 Panel:
- @CyberChargeJoe
- @MasterOfCoins from MyCoralApp
- @MelosBoom
- @Dr_lovelyman from Tap protocol
- @YProselkov from WebKey01
Don't miss it! CyberCharge
Like👍, Retweet🔁, Comment
Link to the tweet!
⚡️CyberCharge – The one charger to power them all!
🔋Revolutionize your energy needs with cutting-edge technology designed for the future.
👉cybercharge.org looking forward to more updates on the #DePIN revolution in energy.
Like👍, Retweet🔁, Comment
Link to the tweet!
We are thrilled to partner with SrcAi_Official!
🚗 SRC ai is an AI-powered Web3 app that monetizes routine driving data, transforming driving habits into recorded and rewarded activities. Monetize your driving data and contribute to the advancement of autonomous tech with SRC ai.
🔋 CyberCharge is the next-generation global power matching protocol and the world's first #DePIN C2E network focused on charging and mining.
We will drive AI and blockchain growth together while exploring new opportunities.
Like👍, Retweet🔁, Comment
Link to the tweet!
💡CyberCharge is the world's first smart charger that combines #Web3 and #DePIN to turn every charge into a digital currency reward while supporting the decentralized Web3 network.
We've got even more rewards for you in Miniapp, where you can draw free treasure chests for tokens like $SOL, $TON, and more!
Let's unleash the full potential of the Cybercharge ecosystem!
After completing all the @taskonxyz 50 winners will receive an equal amount of gems with a total value of $200!
Join: https://taskon.xyz/quest/404918461
🤖Earn NOW📱X(Twitter) 📱Chat💬Discord📱YouTube
⚡️CyberCharge is proud to sponsor the R3alWorld Summit 2024 at #TOKEN2049 .
🤝Join us in Singapore as we showcase the future of decentralized energy solutions and participate in key discussions on the #DePIN industry
Like👍, Retweet🔵, Comment
Link to Tweet
🎁Join our Airdrop Event
Link to MiniApp
Link to IoTeX tweet:
The Future of DePIN: Energy at its Core
⚙️DePIN is transforming Web3, enhancing energy security and adaptability with real-time distribution and monitoring.
⚡️In Low-Voltage transmission, it boosts safety, responsiveness, and efficiency.
#CyberCharge#DePIN
Like👍, Retweet🔵, Comment
Link to Tweet
🤖Join Bot🐣X (Twitter)✉️Chat
Don't miss out #CyberCharge Charger 🥳
Check out the tweet below to learn how to enter the biggest #DePIN giveaway IN HISTORY. 👇
Click Here
Like👍, Retweet🔵, Comment
Link to Tweet
🎁Join our Airdrop Event
Link to MiniApp
🤝#CyberCharge is teaming up with @Weaver_Labs, leaders in Telecom and #DePIN innovation!
📡Weaver Labs is transforming the telecom industry with blockchain-powered decentralization via Cell-Stack, making connectivity accessible for everyone!
🔋CyberCharge, the world's first DePIN C2E network, combines charging and mining, powered by a global weak-voltage power matching protocol.
Like👍, Retweet🔵, Comment
Link to Tweet
🎁Join our Airdrop Event
Link to MiniApp
🚀#CyberCharge is kicking off its Global Tour at @token2049 Singapore!
📍First stop: Marina Bay Sands, 18-19 September 2024.
🤝Come visit our Main Event Booth M126 (Level 4) and experience the future of #DePIN innovations firsthand
Like👍, Retweet🔵, Comment
Link to Tweet
🎁Join our Airdrop Event
Link to MiniApp