Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
News: Overloaded Isuzu truck carrying dozens atop grain overturns, leaving at least 19 dead in #Amhara region
The accident shows the persistent risks associated with the widespread use of cargo trucks for passenger transport in rural Ethiopia, where limited transport options, now exacerbated by chronic fuel shortages across the country, often force residents to travel under dangerous conditions.
Many of the victims were residents of the same locality, often traveling together in groups for work between Tsagibji and Ebnat localities. “Yesterday [Sunday] alone, we sent 17 bodies back to one specific area,” the official said, adding that several victims were members of the same families.
The Deputy Commander also said the area where the accident occurred has been under the control of Fano fighters for the past three years, preventing authorities from reaching the scene to investigate the cause of the crash.
https://addisstandard.com/?p=56655.
In Defense of the Amhara Cause: An Open Letter to Mehdi Hasan. Read more. https://borkena.com/2025/11/29/in-defense-of-the-amhara-cause-an-open-letter-to-mehdi-hasan/@mehdirhasan@AJHeadtoHead#Ethiopia#Amhara
Targeting the Amhara Intelligentsia: Killings, Detentions, and the Legal Threshold of Genocide Under International Law. Read more.
https://borkena.com/2026/02/08/ethiopia-targeting-the-amhara-intelligentsia-killings-detentions-and-the-legal-threshold-of-genocide-under-international-law/#Ethiopia#politics#Amhara
Targeted And Forgotten: The Persecution, Displacement, Mass Killing, and Mass Arrest of the Amhara People in Ethiopia . Read more.
https://borkena.com/2026/03/29/ethiopia-targeted-and-forgotten-the-persecution-displacement-mass-killing-and-mass-arrest-of-the-amhara-people/#Ethiopia#Amhara#HumanRights
Amhara Suffering and the Crisis of Overcrowded Prisons in Ethiopia. Read more.
https://borkena.com/2026/01/11/ethiopia-amhara-suffering-and-the-crisis-of-overcrowded-prisons-in-ethiopia/#Ethiopia#Amhara#humanrights
A War Declared On Amhara — And Its People. Read more.
https://borkena.com/2025/12/06/ethiopia-a-war-declared-on-amhara-and-its-people/#Ethiopia#Amhara#humanrights
#Ethiopia: Federal Police say its forces "seize illegal weapons" intended for "terrorist purposes" after arriving in #Addis_Abeba from #Amhara region
Addis Abeba: The Ethiopian Federal Police claimed its forces have “seized illegal weapons”, “intended for terrorist purposes” after the arms allegedly arrived in Addis Abeba “from the Amhara region.”
In a statement, the Federal Police said the first seizure occurred at the Legetafo checkpoint, where officers “intercepted a vehicle”.
Following what the federal police claimed as a “rigorous inspection,” authorities discovered “eight AK-47 assault rifles, 151 rounds of AK-47 ammunition, 17 rounds of Bren machine gun ammunition, and seven AK-47 magazines concealed inside the vehicle.”
“The illegal weapons were being transported for terrorist purposes,” the Federal Police said, adding that the suspects were “detained at the scene.”
https://x.com/addisstandard/status/2037186920086733010?s=20
Just War and the Fano Struggle: A Brief Moral Evaluation. Read more.
https://borkena.com/2026/01/28/ethiopia-just-war-and-the-fano-struggle-a-brief-moral-evaluation/#Ethiopia#Fano#Amhara#Politics
Evaluating ‘Amhara Fano Unity’ and its Unrealistic Exaggerated Concerns. Read more.
https://borkena.com/2025/12/31/ethiopia-fano-evaluating-amhara-fano-unity-and-its-unrealistic-exaggerated-concerns/#Ethiopia#news#Fano#Amhara
Ethiopian Rebels Claim They Have killed 45 Gov’t Soldiers in Gojjam. Read more. https://borkena.com/2025/12/25/ethiopian-rebels-claim-they-have-killed-45-govt-soldiers-in-gojjam/#Ethiopia#news#Amhara#Fano