Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
#South Africa
The penguin colony of more than 3,000 individuals lives on the beach of Bolders. The penguins adapted to the climate perfectly and does not experience any problems and worries at all.
#South Korea
🇰🇷🤝🇺🇿
🇺🇿 Janubiy Koreyaning Lotte foundation mukofoti “Koreys filologiyasi” yoʻnalishi talabalariga topshirildi.
—
🇷🇺 Премия южнокорейского фонда Lotte foundation вручена студентам факультета «Корейская филология»
—
🇬🇧 The scholarship of Lotte Foundation (South Korea) was presented to students of the Faculty of Korean Philology.
👩💼Read more: www.kiut.uz
20 casualties among Israeli soldiers after Hezbollah thwarted their infiltration attempt in Adaisseh, on the Lebanese border.
#Israel#Lebanon#Hezbollah#South
South Africa may choose Russia and Iran for its nuclear project
South Africa is considering cooperation with Russia and Iran to expand its civilian nuclear capacity, a move that could complicate relations with the United States and delay the renewal of a strategic energy deal between the countries, Reuters reports.
South Africa, home to the continent's only nuclear power plant, the Koeberg, is planning to add 2,500 megawatts of new capacity to combat power outages and reduce emissions. The country has announced a tender and, according to Minerals and Petroleum Resources Minister Gwede Mantashe, Russia and Iran will not be excluded from it.
"If their proposals are the best, we will choose them," he stressed.
The statement has caused concern in Washington. Earlier, US President Donald Trump signed an executive order limiting aid to South Africa, citing its alleged military and nuclear cooperation with Iran. South African authorities have denied the allegations.
A South African nuclear tender planned for last year has been delayed by legal wrangling. Meanwhile, work is underway on a new US-South African nuclear cooperation agreement (the 123 Agreement), which is needed to export nuclear technology and fuel from the US.
The previous agreement expired in 2022. According to Zizamele Mbambo, an official in the South African Department of Energy, the negotiations have been completed at a technical level, but the signing is being delayed by legal procedures.
Analysts say South Africa's decision to turn to Russia and Iran could heighten geopolitical tensions and slow the restoration of cooperation with the US.
#AREA#South Africa #Russia#Iran#USA
News: #Tigray institutions renew calls for dialogue, reconciliation amid continued internal clashes
Religious and civic institutions in Tigray have renewed calls for dialogue and an end to internal fighting, urging combatants to halt hostilities and pursue reconciliation as clashes continue in parts of the region, despite recent signs of de-escalation in the #south.
The Synod of the #Selama Tigray Orthodox Tewahedo Church, following an emergency meeting, said that “the mutual destruction occurring between brothers must stop,” and announced plans to actively engage in efforts to end the killings.
In a statement shared with journalists, the Synod said that as people in Tigray face one of the gravest crises in recent history, it is seeking to foster understanding and reconciliation to bring an end to internal violence.
Similarly, Tigray #Public_Diplomacy issued an emergency statement titled “Stop the War: Let Us Return to Dialogue,” recalling an earlier...
Read more: https://addisstandard.com/?p=55017