Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
Bob Suberi, a U.S. and Israeli citizen and veteran, calls himself a “recovering Zionist.” Now in his third year attempting to help break Israel's illegal siege of Gaza on 'Handala', he’s taking direct action once again. After years working in Palestinian solidarity in the West Bank, Suberi is urging others, especially in the Jewish community, to speak out: “Let’s talk openly about a genocide. We’ve spent decades saying ‘Never again,’ and yet we’re justifying it.”
#BreakTheSiege#BreakIsraelsSiege#EndTheBlockade#Handala#FreedomFlotilla#StandWithGaza#StandWithPalestine
Thousands of people are rising across continents - on foot, in boats, in streets and squares - to say no more.
No more siege. No more starvation. No more occupation. No more genocide. From the river to the sea, Palestine will be free. Follow and support March to Gaza today.
#BreakTheSiege#MarchToGaza#EndTheBlockade#GlobalMarchToGaza#StandWithPalestine
Nicole Jenes came to Malta to stand with the Freedom Flotilla's humanitarian action, not as an act of "rebellion", but as a reflection of what it means to be human. “This is the natural reaction to genocide, to Apartheid, to silence.” Despite drone attacks targeting the ship, no one is deterred. The volunteers and our supporters are undaunted, and together, we will push forward to Gaza. The power to break injustice lies within us. No more waiting. No more excuses.
SIGN THE PETITION - https://bit.ly/alleyesondeck
#AllEyesOnDeck#FreedomFlotilla#NicoleJenes#StandWithGaza#StandWithPalestine#BreakIsraelsSiege#EndTheBlockade
Now with Israel's attack on Iran, the airports are shut down, and our three remaining 'Madleen' team members, Pascal Maurieras, Yanis Mhamdi, and Marco van Rennes may face an extra month, illegally detained in Israeli prison.
All three were meant to be released and flying back to their families today, June 13. The French and Dutch governments must find alternative routes and get their citizens home, whether through Jordan or otherwise - NOW.
Contact details in our slides and email template in our stories.
#BreakIsraelsSiege#EndTheBlockade#Madleen#WeWillSail#AllEyesOnDeck#StandWithMadleen#StandWithPalestine
Freedom Flotilla Official Update: It's time for our governments to do their jobs and sanction Israel. Its illegal attack on 'Madleen' while sailing in international waters is a small extension of their war crimes in Gaza. Governments, institutions, media, and corporations must stop protecting Israel, now. They must stop prioritising profit over human lives, now. Protect our volunteers while protecting Palestinians in Gaza and wider Palestine.
#BreakIsraelsSiege#EndTheBlockade#Madleen#FreedomFlotilla#Volunteers#IOF#StandWithGaza#StandWithPalestine
Israel’s attack on an unarmed humanitarian vessel in European waters, and the government silence that followed, is part of a wider pattern: 19 months of Israel's relentless violence in Gaza and 77 years of impunity across occupied Palestine.
While Malta’s newly released report confirms what we already knew, there has still been no condemnation issued. No investigation. No accountability.
As we prepare to sail again with ‘Madleen’, we do so knowing our ships remain targets, not only of Israeli aggression but of global inaction.
We call on governments to guarantee safe passage, on media to report the truth, and on people everywhere to demand an end to Israel’s siege and ongoing genocide:
– Share this post and tag the EU Commission and your MEPs
– Sign our petition to demand an independent investigation
– Demonstrate at weapons manufacturers
– Keep #AllEyesOnDeck as ‘Madleen’ sails
#BreakTheSiege#EndTheBlockade#StandWithGaza#StandWithPalestine#EU#Malta#Conscience
Freedom Flotilla Official Update: It's time for our governments to do their jobs and sanction Israel. Its illegal attack on 'Madleen' while sailing in international waters is a small extension of their war crimes in Gaza. Governments, institutions, media, and corporations must stop protecting Israel, now. They must stop prioritising profit over human lives, now. Protect our volunteers while protecting Palestinians in Gaza and wider Palestine.
#BreakIsraelsSiege#EndTheBlockade#Madleen#FreedomFlotilla#Volunteers#IOF#StandWithGaza#StandWithPalestine
"The governments of the world failed to provide safe passage to the Madleen, to allow humanitarian aid to the people of Gaza, who have been facing ethnic cleansing for 80 years and an illegal blockade for 18 years. To prevent ongoing Israeli war crimes they must immediately step up, oppose the apartheid regime of Israel and provide safe passage to the Sumoud convoy in Egypt. The time to act is now. Free Palestine!"
Mark Van Rennes
#FreePalestine#SumoudConvoy#MarchToGaza#Madleen#StandWithGaza#StandWithPalestine#FreeMadleen#WeWillSail#BreakTheSiege#BreakIsraelsSiege#EndTheBlockade