Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
Plea in Calcutta High Court challenging ECI decision to deploy only employees of Central Government and PSUs as counting supervisors.
Single Bench to hear the Case at 2 PM #Judiciary
Calcutta HC (Single Bench) overturned the Election Commission order to Ban Bikes in Poll Bound Areas from 48 hrs to just 12 hrs.
This Ban was imposed in Phase I but overturned on April 24. Now Election Commission has moved to Division Bench of Calcutta HC to appeal against this order.
#Judiciary
Election Duty Officers move SC saying they themselves are not on West Bengal SIR List
Se Adv MR Shamshad: These are 65 petitioners who are on Election duty. Their duty orders mention EPIC numbers. Now those numbers are deleted. Now the persons conducting elections cannot vote! This is on the face Arbitrary. Many not given reasons.
CJI: Make these arguments before the Appellate Tribunal. Let the tribunal look into it.
Justice Bagchi: Appropriate orders will be passed by the Tribunal. This election yes perhaps they can't vote. The more valuable right to remain on the Rolls shall be preserved.
#Judiciary
Center says the SC "Government doesn't want to control the temple at all"
Center also conveyed SC directly that it is not competent to decide on matters of belief and practices of Religious Denominations and should restrict itself to matters of Constitution.
#Judiciary
Center to Supreme Court
Decriminalising adultery and Same-Sex consensual relationships were based on a "subjective" interpretation of constitutional morality and should be considered "not a good law."
Solicitor General Tushar Mehta –
" Constitutional morality" is a vague concept and cannot serve as a standalone test for Judicial Review of laws. He said in a democracy, laws reflect the will of the majority, raising questions about how morality should be defined in that context.
#Judiciary
🇺🇸New York Courts Establish Formal AI Use Policy for Judges and Staff
New York Unified Court System has issued its first official policy governing the use of generative AI by judges, justices, and court personnel. The interim rules limit the use of AI to approved tools and mandate training for all users. The policy explicitly prohibits entering confidential or privileged information into any generative AI tool that is not operated as a private model under the control of the court system.
The document emphasizes that judges and staff remain fully responsible for their work product and must ensure that AI output does not reflect harmful bias, stereotypes, or prejudice. “While AI can enhance productivity, it must be utilized with great care,” said Chief Administrative Judge Joseph Zayas. “It is not designed to replace human judgment, discretion, or decision-making.”
#AI#AIethics#Judiciary#AIGovernance
#HongKong’s top court plans to appoint New Zealand judge William Young, sparking protests in New Zealand. Critics accuse him of endorsing Hong Kong’s #CCP-controlled judiciary, which has jailed thousands of #politicalprisoners facing unfair trials.
Protesters gathered outside Young’s office, demanding he reconsider. When Hong Kong journalists asked for comment, Young replied:
“I would not accept appointment unless satisfied it was proper. Apart from that, I have nothing to add and won’t debate my appointment.”
His decision raises concerns about legitimizing #Beijing’s judicial control.
#Judiciary#CourtOfFinalAppeal#CCPControl
#香港#終審法院 計劃任命新西蘭法官楊威廉 ,在紐西蘭引發抗議。批評者指責他為中共控制的司法制度背書 ,該制度已讓數千名 #政治犯 遭受不公正審判。
抗議者在楊威廉的辦公室外集會,要求他重新考慮。香港記者向他提問,他回應:
「除非確信適當,否則不會接受任命。此外,我沒有新內容可補充,也不會討論此事。」
#中共控制