Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
GM OneEarth community, it's been a while! 🎆
Venue:X Space
Special Guest:@MissWRosa@woxiangni1997
🗓 May 15th 10 PM UTC+9
💰$100 #Giveaways👇
1️⃣Join the Bot :OneEarth Bot
2️⃣ Ask questions in Comment
3️⃣ Like & RT
Remember: One Earth, One Community! 🌎⚡️
✨ Giveaway: Creative Ways to Hide Your Tangem Wallet
🥳Our Discord Community Turns 1!
Celebrate with us by showing off your creativity in our special anniversary giveaway!
Are you a master of concealment? We’re challenging you to come up with the most fun hiding places for your Tangem Wallet. Whether it’s hidden in a book on your shelf or tucked behind a secret panel, we want to hear your best ideas!
🏆 5 Tangem branded Hoodies to be won on Discord in the #giveaways channel
👀 How to Enter:
Share your creative hiding spots in the #giveaways thread → top ideas, as voted by our community members, will win.
📅 Dates: Enter until the 28th June → 1st July we do a community vote → then we share the winners!
Cheers to the next year of the Tangem Community - to health, stealth, and wealth!
👾Join Discord and take part in contest →https://discord.com/invite/tangem
📰You can make your payment via @Premiumbot or Fragment to activate Giveaways
Currently, because this service is not ready, you'll receive ACCESS_DENIED message from the bot.
#Giveaways
👉The TG Times
📰Win Telegram Premium
By having all the conditions to receive Telegram Premium Gift from the channels, among the participants in this Giveaway, the desired number will be randomly selected to receive this gift.
After winning, a message containing the link to activate this subscription will be sent to you via Telegram.
You can also share this link with your friends so that they can get this subscription.
#Giveaways
👉The TG Times
📰New options for Giveaways
You can enable Additional Prizes if you want to give the winners your own prizes in addition to Premium subscription.
Also you can choose whether to make the list of winners public when the Giveaway ends.
#Giveaways | #Beta v.10.4
👉The TG Times
📰Giveaway Prizes
Giveaway Premium subscriptions to your channel members
Telegram is launching a new system to upgrade channels, where channel admins can create Premium Giveaways and set conditions such as location and date for them and boost their channels in this way.
This system is not yet fully available and can only be accessed on the test server.
Giveaway sources: @betawatch
#Giveaways | #Beta v.10.2
👉The TG Times
📰Giveaways are getting ready to be activated on the main server
Telegram beta configuration updates in each version make the Giveaways more complete and prepare for official presentation.
This system was active for some to receive more boosts from the first release of the beta version 10.2.0 on the test server.
Also, multiple boosts and the possibility of boosting more by giving a Premium gift are not activated on the main server, which can be related to the Giveaways.
It is expected that this system will be launched soon in the next updates for the main server.
Configurations by @tgcrawl
#Giveaways | #Configuration
👉The TG Times
Tonnel Network: New Measures Against Bot Farms in Giveaways
#giveaways#restrictions
Tonnel Network has enhanced measures to combat bot farms that manage to bypass restrictions in giveaways. Channel owners are encouraged to set at least one restriction to ensure the integrity of their free giveaways.
Source: link
@tonlines