Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
#Yangiyul
Animals in the municipal veterinary service are dying without access to food and water
A situation causing serious concern among animal rights activists and the public has been reported in the city of Yangiyul. According to them, an institution that is supposed to provide care and treatment for animals has become the center of a scandal due to improper conditions in its quarantine facility.
Reports indicate that animals in the isolation unit are being kept without access to food and water. Of particular concern is an injured dog that urgently requires veterinary care. However, activists claim that no necessary treatment or care is being provided.
Elena Vladimirovna Babenko, a member of the Public Council under the National Committee on Ecology and Climate Change, contacted the Veterinary Committee’s hotline (71 202 12 00, ext. 201). She was informed that the situation would be reviewed and appropriate measures would be taken.
Despite these assurances, volunteers say that no changes have occurred on site. A volunteer named Asiya attempted to deliver medication, water, and food for the animals, but was denied access to the facility.
Animal rights activists insist on an urgent inspection by the relevant authorities and a legal assessment of the situation.
☘️Read the latest environmental news on the @ekologuz page. Follow us and send your suggestions and wishes via @eklguz_bot
Instagram | Facebook | Twitter | Sayt | Youtube.
🚨 Lawlessness or rule of law? A zoo volunteer’s home attacked in Yangiyul
The conflict between animal rights defenders and the animal control service has escalated into open confrontation. According to volunteers, the situation has already gone beyond legal boundaries and is infringing on fundamental civil rights.
Animal welfare activists Asiya Abuzyárova and Svetlana Velichko reported that about 30 dogs disappeared from the territory of a municipal improvement enterprise. After attempts to return the animals, pressure reportedly began: a complaint was filed with the police, a volunteer was attacked, her phone was broken, and activists were allegedly harassed.
❗️ The most serious incident was the forced entry into a private home.
According to reports, municipal workers used a ladder to break a window and enter Asiya Abuzyárova’s house, forcibly removing the animals inside. When the homeowner resisted, her phone was destroyed and her hand was injured.
⚖️ According to the legislation of Uzbekistan:
🔹 The home is inviolable — entry without the residents’ consent is allowed only on legal grounds or by court order.
🔹 Private property is protected by the state — damage to property and unlawful seizure are prohibited.
🔹 Any actions by officials must have legal grounds and be properly documented.
This may constitute unlawful entry into a residence, abuse of authority, and violation of citizens’ rights.
📢 Key questions arise:
✔️ On what legal basis were the animals seized?
✔️ Who authorized the entry into the home?
✔️ Why are reports of property damage and injuries being ignored?
The law must apply equally to everyone — both citizens and officials. The situation requires a transparent investigation and a legal assessment of the actions of all parties.
#Yangiyul#civilrights#animalprotection#ruleoflaw
☘️ Follow the latest environmental news on @ekologuz. Send your suggestions and feedback via @eklguz_bot
🐾 Where are the dogs disappearing in Yangiyul?
At the temporary dog holding center (shelter) in Yangiyul, on February 10, volunteers recorded the dogs in the shelter. According to the volunteers, almost no adult dogs remained — all of them were reportedly killed overnight.
A day earlier, many dogs were in the shelter, but when the volunteers visited, they saw only 5–6 dogs in the cages. The question is: where did the rest of the dogs go? Volunteers say they were killed.
According to the volunteers, tomorrow the remaining poor dogs on Persidskaya Street — who are already afraid of every little sound — are also scheduled to be killed.
💔 This is not just statistics. This is a matter of our humanity.
#ProtectAnimals#Yangiyul#AgainstCruelty#Ethics#Animals
☘️Read the latest environmental news on the @ekologuz page. Follow us and send your suggestions and wishes via @eklguz_bot
Instagram | Facebook | Twitter | Sayt | Youtube