Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
Tareq, from Gaza, was one of the dozens of international volunteers, ready to sail to Palestine with aid and revolutionary hope. This is why he joined the Freedom Flotilla Coalition, and why we must continue fighting for the 'Conscience', which is currently still stranded in international waters. #AllEyesOnDeck#FreedomFlotilla#StandWithGaza. ⬇️
Gaza is being destroyed, and the Arab world is silent!
Israel is raining fire on Gaza day after day.Beneath the bombs and rockets, the ground trembles, but even more, a mother’s heart shakes in fear.
Children no longer ask for toys—they beg for safety.Women don’t seek adornments—they yearn for a chance to survive.
And us?
Most Arab leaders stay mute. Some even shake hands with this oppressor.While the Muslim nation drowns in blood, they’re lost in luxury and self-interest.
But Allah sees.He hears the cries of the oppressed.One day, the tyrants will face justice—no one will escape.If we stay silent today, history will curse us tomorrow.Pray for Gaza, speak up, stand for truth.
#FreePalestine🇵🇸
#StandWithGaza
#StopGenocide
#SaveHumanity
I rarely use the word "hero" for individuals, as I believe true heroism often lies in collective acts—like the unwavering spirit of the people of Gaza. But the justice and solidarity activists on the Gaza Freedom Flotilla, Madleen are undeniably heroes. They embody both individual courage and a global shift towards solidarity with Palestine, standing against the Israeli genocide in Gaza.
Thank you to everyone on the Flotilla and to all who supported their valiant efforts.
#GazaFreedomFlotilla#FreePalestine#StandWithGaza#EndTheGenocide#GazaGenocide#Gaza
Our 'Madleen' was on a mission of urgency after a year of set backs, carrying baby formula, food, medicine, and basic humanity. Then came unidentified vessels, speedboats, quadcopters, and finally, Israeli soldiers. Francesca Albanese recounts what happened in real-time as she spoke to the crew live. She reminds us that 'Madleen' was a UK-flagged boat seized in international waters. Israel's interception is an act of piracy. Abduction is illegal, as is their siege, genocide, occupation and countless other war crimes across Palestine. So what makes a small, aid boat so scary for the Israeli occupation? According to Francesca Albanese: it is our humanity. It is everyone's defiance. It is our collective power to break the siege.
#BreakIsraelsSiege#EndTheBlockade#StandWithGaza#FrancescaAlbanese#Madleen
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
The Freedom Flotilla Coalition invites you to join us from May 30th to June 1st in Catania, Sicily, Italy, as we stand together in solidarity to launch our new mission, the ‘Madleen’.
The summit will be happening in Porto di San Giovanni li Cuti, where we will stand in solidarity with the Palestinian people in a series of panels, cultural programs, and community gatherings.
The ‘Madleen‘ will sail to break Israel's illegal siege as we bring humanitarian aid, hope, and solidarity to Gaza. The world stands united against the deliberate starvation, genocide, Apartheid, colonial occupation, and the ethnic cleansing of the Palestinian people. Join us!
Let's sail in spirit and solidarity. Free Palestine!
#FreedomFlotilla#BreakIsraelsSiege#EndTheBlockade#StandWithGaza#AllEyesOnDeck#Madleen#Conscience
Meet just some of the panelists, volunteers and supporters that will join us as we launch the ‘Madleen’ that will sail in a matter of days to break Israel's illegal siege of Gaza.
We urge media, press and supporters to join us in Catania, Sicily - your coverage and solidarity is critical in helping ensure our safety. March with us. Make noise with us. Show the world that Europe will not be silent. Share our content. Make it impossible for every politician, for the European Union and media to ignore what is happening in Gaza. Make it impossible for them to ignore the voice of the people, to ignore this mission, and to ignore this moment.
#BreakTheSiege#BreakIsraelsSiege#AllEyesOnDeck#EndTheBlockade#StandWithGaza#AllEyesOnDeck#Madleen#Conscience
Macklemore endorses the Freedom Flotilla’s ‘Madleen’ on stage, playing a special video that Greta Thunberg recorded from the vessel. Keep all eyes on deck, and all eyes on Palestine.
#GretaThunberg#Macklemore#BreakIsraelsSiege#EndTheBlockade#StandWithGaza#FreePalestine
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
After drones repeatedly hovered over the ‘Handala’ last night, we need people of the world to help tag and email their foreign ministry. The volunteers aboard are delivering life-saving aid to Gaza. They are unarmed, carrying only food, medicine, and baby formula, and acting fully within international law.
It’s time for world governments to step up. Demand they protect their citizens aboard the 'Handala' and stop enabling Israel's war crimes.
Safe passage is a legal obligation, and a moral one.
#Handala#SafePassageNow#HumanitarianAidIsNotACrime#WeWillSail#AllEyesOnDeck#StandWithGaza#BreakIsraelsSiege
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
Six of the seven U.S. citizens aboard the Freedom Flotilla’s ‘Handala’ just read a powerful open letter to Donald Trump and the U.S. government. From the founder of Amazon Labor Union’s to a U.S. war veteran, a lawyer, a marine rescue worker, a human rights attorney, and an actor—each one delivered a searing truth: the U.S. is an active participant in Israel’s war crimes against Palestinian children in Gaza. If the U.S. does not support the deliberate starvation of children, they should guarantee safe passage of ‘Handala’.
‘Handala’ plans to deliver food, medicine, and baby formula to Gaza in a few days. They are unarmed, trained in nonviolence, and yet, are under threat by Israel. If anything happens to them, the world will know who is responsible.
Share this. Tag your politicians. Break the silence. Let the world see who’s standing on the right side of history.
#PresidentTrump#Handala#SafePassage#FreedomFlotilla#ForTheChildrenOfGaza#StandWithGaza#AllEyesOnDeck