Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
🌎 The planet’s oldest living animal is the deep-sea quahog clam. One specimen, named Ming, lived to be 507 years old before being discovered near Iceland. ✨
#ocean⚡#longevity⚡#animals
👉subscribe Interesting Planet
🌍 Some of the world’s oldest lakes, like Lake Ohrid in Europe, have existed for more than one million years, preserving unique species found nowhere else on Earth. ✨
#lakes⚡#biodiversity⚡#longevity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌎 In the Himalayan foothills, the Kalpavriksha, or “tree of heaven,” is a fig tree revered for living over 2,500 years. Its resilient roots stabilize soil and support hundreds of animal species, making it both a cultural icon and a pillar of its ecosystem. ✨
#botany⚡#longevity⚡#wildlife
👉subscribe Interesting Planet
🌎 The Welwitschia mirabilis, found only in the Namib Desert of Namibia and Angola, survives on coastal fog and can live over 1,500 years. Its two long leaves grow continuously, shredding into ribbons that cover the sand around the plant. ✨
#botany⚡#desert⚡#longevity
👉subscribe Interesting Planet
👉more Channels
🌎 In Namibia, the welwitschia mirabilis plant survives for over 1,000 years with just two leaves! These tough leaves grow nonstop, curling and splitting in the harsh desert. ✨
#botany⚡#desert⚡#longevity
👉subscribe Interesting Planet
🌎 Giant tortoises from the Galápagos and Aldabra islands are true living fossils. Their ancestors appeared over 40 million years ago, and some individuals today can live more than 150 years. ✨
#evolution⚡#reptiles⚡#longevity
👉subscribe Interesting Planet
👉more Channels
🌎 High in the Andes, the Yareta plant forms cushion-like mounds that can live for over 3,000 years. Its dense, bright-green surface helps conserve heat, allowing it to survive freezing mountain nights. ✨
#plants⚡#longevity⚡#mountains
👉subscribe Interesting Planet
🌎 The Pando aspen grove in Utah is a single living organism made up of 47,000 genetically identical trees, all connected by one massive underground root system. This silent giant is considered one of the world’s largest and oldest living things, possibly dating back 14,000 years. ✨
#trees⚡#biology⚡#longevity
👉subscribe Interesting Planet
🌎 The Californian coastal redwoods are the tallest living trees on Earth, soaring over 115 meters high. Their thick bark and tannins protect them from fire and insects, letting these giants live for thousands of years. ✨
#trees⚡#forest⚡#longevity
👉subscribe Interesting Planet
Jrnys Secures $8.65M Funding
Jrnys has raised $8.65 million to enhance personalized healthcare focused on weight loss solutions using GLP-1s like Zepbound, Mounjaro, Ozempic, and Wegovy. The company also addresses Sexual Wellness, Haircare, and Longevity needs.
#Funding#Healthcare#WeightLoss#GLP1#Zepbound#Mounjaro#Ozempic#Wegovy#SexualWellness#Haircare#Longevity
DeSci Gains Momentum Amid Innovation
Decentralized science (DeSci) is gaining traction with recent developments:
1️⃣Bio Protocol joins Binance Launchpool as the 69th project, focusing on decentralized science token launches. So far, 7 projects have raised $23M, with $7M allocated for research. More info here.
2️⃣Pump.science launches, allowing community-driven scientific experiments, starting with a longevity project. Their collaboration with Pulse will use health data metrics for future experiments. Learn more about Pump.science.
3️⃣ The Sci-Hub token has been introduced on pump.fun, providing access to scientific papers; the founder promotes purchasing the token to support open science. Token details here and Sci-Hub info here.
While still niche compared to AI and meme coins, DeSci is attracting interest, paving the way for wider community involvement. Let's observe how DeSci progresses into 2025!
#DeSci#BioProtocol#Binance#PumpScience#SciHub#Token#Research#Innovation#Web3#Community#HealthTech#Crypto#Launch#Investment#Experimentation#Longevity#OpenScience#Funding#Technology#Blockchain#Ethereum