Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
📚 Slex Empowering Education for Crypto Enthusiasts!
🎓In a rapidly changing crypto industry, it is essential to constantly gain new knowledge. Slex platform will equip users with the knowledge they need to thrive.
📖 Comprehensive Resources: We provide an extensive library of in-depth guides, webinars, courses, and resources for understanding the market better and making informed decisions.
🤝 Community Engagement: We plan to regularly organize workshops, webinars, meetups, and other engaging events to foster a vibrant community of crypto enthusiasts.
Stay tuned for more updates as we approach the launch of Slex! Join us on this educational journey and discover the possibilities of the crypto industry.
👉 Join Slex now: slex.io/registration
#Slex#CryptoEducation#CryptoEducation
Email | Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
☄️Tether has exceeded Germany 🇩🇪 in terms of U.S. Treasury holdings, now sitting at the 19th position globally with $91 billion in bonds as of March 31st. Paul Ryan, former Speaker of the House, recommends regulating stablecoins given Tether's noteworthy influence on the digital dollar.💵🕯
#Cryptoeducation
#Bitcoinnews
#Cryptolover
🕯Price analysis 5/30: BTC, ETH, BNB, SOL, XRP, DOGE, TON, SHIB, ADA, AVAX
💰Bitcoin remains in sideways price action, but a positive sign is that the investors have continued to buy the spot Bitcoin exchange-traded funds.
💰Farside Investors data shows net positive inflows into the ETFs for the past 11 days.
#Cryptoeducation
#Bitcoinnews
#Cryptolover
#Cryptosignals
Most people lose in crypto not because of the market, but because of emotions.
The solution is simple: accumulate BTC in small satoshi amounts regularly.
You can start with $100 today. This is not financial advice.
@saylor@APompliano@aantonop
#Bitcoin#BTC#Sats#HODL#CryptoEducation#MyMining
🔖Shiba Inu Super Diamond Trader Liquidates Holdings, Followed By A Secret Message 📣
#Cryptoenthusiast
#Cryptocurrencies
#Cryptowallet
#Cryptoeducation
#Bitcoinnews
🚀 Binance Launches Word of the Day Game with BNB Rewards
According to the announcement from Binance, the platform has introduced a new Word of the Day (WOTD) game, themed "Team Up with Binance." This educational initiative aims to enhance users' crypto vocabulary while keeping them informed about the latest market trends. The activity period is set from 2026-04-13 00:00 (UTC) to 2026-04-19 23:59 (UTC).
Participants can engage in up to two WOTD games daily, testing their knowledge on the specified topic. Users who correctly answer at least three questions during the activity period will qualify to share a 15 BNB reward pool. The distribution of rewards will be proportional to the number of correct answers each user provides, with a maximum cap of 0.01 BNB per user. Rewards are scheduled to be distributed to winners' Spot Accounts by 2026-05-03 23:59 (UTC).
To access a second WOTD game, users must click the "Get A New WOTD" button after completing the first game. Sharing the featured link on social media and having it clicked by a logged-in user will unlock the second game. Additionally, new users registering with the "WOTD" referral code during the activity period will receive a 10% discount on Spot trading fees. They may also earn additional welcome rewards by completing tasks in the Rewards Hub within 14 days of registration.
Binance reserves the right to modify or cancel the promotion without prior notice and may update the list of eligible countries or regions. Participation is subject to Binance's terms and conditions, and users must complete account verification to be eligible for rewards. The platform emphasizes that any fraudulent activity or violation of terms may lead to disqualification from the promotion.
#Binance#WordOfTheDay#WOTD#BNB#CryptoEducation#CryptoRewards#CryptoGame#SpotTrading#ReferralCode#RewardsHub#Blockchain#CryptoLearning#CryptoCommunity