Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
LinkedIn’da topilgan maslahat:
Professional o’sishni tezlashtirish va atrofdagilardan farq qilish uchun biror soha yoki yo’nalishda “go-to-person”ga aylanish. “Go-to-person” - biror muammo yoki savol tug’ilganda murojaat qilinadigan odam: yo’nalish kattaroq kodning bir qismi, test qilish, biror freymvork, Kubernetes, Docker, biror usul va hokazo bo’lishi mumkin. Shu yo’nalishni topish va shu bo’yicha hamma suyanadigan, boradigan odamga aylanish odamning professional o’sishiga juda katta yordam beradi.
@farhodjon#growth
🌍 In November 2022, the world’s population reached 8 billion for the first time, doubling in just 48 years since 1974—a record pace in human history for global population growth. ✨
#population⚡#demographics⚡#growth⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 In 2023, India gained over 13 million people—more than the total population of some countries. This rapid growth boosts its status as the planet’s most populous nation. ✨
#population⚡#demographics⚡#growth⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 In 2023, Ethiopia recorded the world’s highest annual natural population increase, adding nearly 2.7 million people in a single year—more than many countries’ entire populations. ✨
#population⚡#demographics⚡#growth⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
Leading Crypto VC Firms to Watch in 2023
Thanks for the feature! 💥
We're proud to be part of this ecosystem.
It's a privilege to be part of this Web3 future.
Let's keep building! ✨
#investment#community#growth
🌍 Over one million people are added to the world population roughly every five days. The fastest-growing regions are now in parts of Africa, where birth rates remain among the highest globally. ✨
#demographics⚡#growth⚡#continents⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
Good morning, good morning! ☀️ Looks like Darius had a good night's rest and is feeling even better than before.
———
Stage 2, Part 1 of the growth drive! Thank you all for your contributions to this - it's still in the works, albeit slowly!
Stage 2, Part 2 is in the works!
#art#growth#nsfw#hyper
Russia expects 3.9 percent GDP growth in 2024
📌 This is the result of a set of applied policies in the field of finance, infrastructure development, digitalization, building a knowledge economy, and improving the level of education of the population.
📌 "It was noted (at the APEC summit - ed.) that in comparison with other regions of the world in the economy (countries - ed.) APEC feel quite comfortable. GDP growth rates in APEC countries exceed the global averageaverage" - Russian Deputy Prime Minister Alexey Overchuk
#news#russia#nido_russia#economy#growth
https://t.me/nido_russia
🌍 The city of Lagos, Nigeria, is predicted to become the world’s most populous city by 2100. Rapid urban growth could bring its population over 80 million, surpassing today’s largest cities. ✨
#population⚡#growth⚡#megacities⚡#urbanization⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
TON is an up-and-coming powerhouse that we're absolutely stoked about⚡
In this video, TON's Head of Incubation, Justin Hyun, shares some exciting insights about Ton Foundation and its role in the #ecosystem.
While TON is younger than other significant Layer 1 blockchains, its rapid #growth and evolution has led it to become one of the hottest projects in the #crypto market in the last month, and it appears that next year will be exciting for TON.
In terms of transaction speed and versatility, TON Foundation remains ahead of other Layer 1 blockchains. In addition to a quick block validation time, the blockchain provides several advanced scalability features, such as sharding support.
Needless to say, we are a fan of this amazing #work and we can't wait to see the innovations that TON is going to bring to this space in the coming years.