Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
🇺🇸🇺🇦🇷🇺Former Virginia State Senator, Col. Richard H. Black (ret.) on murder ofDugina
"[...]Just this week, Daria Dugina, the daughter of an activist, a pro-Russian activist, was murdered in Moscow, apparently by a Ukrainian assassin who killed her using a bomb that exploded under her car, ripping her body to pieces and burning her to death. Since the United States has admitted being involved in targeting 13 Russian Generals for assassination in Ukraine, it is possible that the CIA provided the targeting information to go after this young woman.
Apparently, they were actually targeting her father. He’s an established pro-Russian pro-war journalist. And they wanted to show that they have the ability to go right into Moscow and to carry out a mafia style hit. So, they did it. I would not be surprised if the CIA provided the targeting information to go after her. It was just a last-minute switch of automobiles that caused the daughter to die instead of the father."
#Dugina#assassination
@american_majority
🇺🇸🇷🇺🇺🇦Former US Marine Corps intelligence officer and UN inspector Scott Ritter:The murder of Daria Dugina was an act of terrorism
'Today, I’m a 61-year-old writer living in the suburbs of Albany, New York. [...] And yet, due to recent circumstances, I once again find myself inspecting my vehicle before getting inside, keeping a watchful eye out for strange vehicles driving down my street and conducting counter-surveillance maneuvers while driving.
Why the paranoia? Simply put, my name has been added to a Ukrainian “kill list.” Think I’m getting too wound up? Ask the family of Daria Dugina, the 29-year-old daughter of the Russian philosopher Alexander Dugin. Both she and her father were on the same list. Both were targeted for death by an assassin dispatched by the Ukrainian security services. [...]
The existence of the Myrotvorets “death list” is an instrument of terror and should be taken down at the insistence of the U.S. Government.'
Source
#Dugina#CIA#Ukraine#assassination
@american_majority
🇺🇸🇺🇦🇷🇺“They Killed Her Because Of Her Ideas”: Russian Political Scientist Valery Korovin on Daria Dugina assissination
"Her death was a serious loss for the global intellectual conservative environment of the opponents of globalization and the very idea of the modern world.
Also, her tragic death as a result of a terrorist act, caused serious damage to the activities of the entire intellectual group headed by the world’s leading philosopher, author of the modern Russian geopolitical school, Eurasianist and intellectual Alexander Dugin.
Serious funds from American taxpayers are spent on personally discrediting Dugin and his movement, one slanderous campaign follows another, the best political technologists are working to discredit Dugin and his ideas in the wake of the State Department and the CIA."
Read the full text
#Dugina#CIA#censorship#Globalists#Biden#Soros
@american_majority
🇺🇸🇺🇦🇬🇧'The beneficiary of the explosion is obvious' - Valery Korovin on Dugina assassination
Russian writer German Sadulaev and political scientist Valery Korovin commented on the killing of Daria Dugina
#Dugina#CIA#MI6#Ukraine#Biden#war#Great_Britain#Soros
@american_majority