Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
Californian Gov. Gavin Newsom labeled JD Vance a “dips--t” in a string of stinging social media posts that included resurfacing images of the vice president in drag.
Vance spoke to reporters after a meeting with President Donald Trump and Democrats on Monday in an effort to avoid a government shutdown that could close services as early as Wednesday.
Little appeared to have been achieved, with both sides blaming the other before the midnight Tuesday deadline.
Newsom shared footage of the vice president from the White House Rapid Response X account pointing the finger at Democrats.
“You don’t put a gun to the American people’s head and say, ‘Unless you do exactly what Senate and House Democrats want you to do, we’re going to shut down your government,’” Vance told reporters outside the White House.
“That’s exactly what they’re proposing out there.”
#Vance#Newsom
👂More on Trump's Ear ⚠️
Academy Award-winning actress Halle Berry lashed out at California Gov. Gavin Newsom on Wednesday, arguing that he overlooks women and shouldn’t “be our next president.”
“At this stage in my life, I have zero f–ks left to give,” Berry said in remarks at the Dealbook Summit before taking aim at the Democratic governor, according to the Hollywood Reporter.
“Back in my great state of California, my very own governor, Gavin Newsom, has vetoed our menopause bill, not one, but two years in a row,” the “Catwoman” star continued. “But that’s OK, because he’s not going to be governor forever, and the way he has overlooked women, half the population, by devaluing us, he probably should not be our next president either. Just saying.”
#Newsom#Hollywood
👂More on Trump's Ear
Il presidente Donald #Trump rilancia su Truth un video generato con intelligenza artificiale che raffigura Barack #Obama e Michelle #Obama come gorilla e ripropone false accuse contro Dominion Voting Systems sulle elezioni 2020, suscitando condanne, tra cui quella dell'ufficio del governatore della California Gavin #Newsom: "comportamento disgustoso da parte del presidente. Ogni singolo repubblicano deve denunciarlo. Adesso".
@UltimoraPolitics24
Gavin Newsom naturally couldn’t resist trolling Donald Trump after the 79-year-old president posted an AI-generated video featuring him he shilling for magic “Medbeds.”
“Trump is about to shut down the government and rip health care from 20 million Americans. What’s he doing? Posting AI-generated slop about ‘miracle hospital beds’ that cure all illness,”
tweeted Newsom, 57.
“DONALD TRUMP HAS LOST IT,”
he added.
#Trump#Newsom#conspiracy
👂More on Trump's Ear ⚠️
Trump's signature will appear on dollar bills for the 250th anniversary of US independence 💵
The signature of US President Donald Trump will appear on new dollar bills that will begin to be printed in 2026. The decision is timed to coincide with the 250th anniversary of the adoption of the US Declaration of Independence, which will be celebrated on July 4, 2026. 🇺🇸
US Secretary of the Treasury Scott Bessent explained that there is no more visible way to celebrate the historical achievements of President Donald Trump than to place his name on dollar bills.
This will be a violation of a tradition that has been in place since the 19th century, when banknotes were traditionally signed by the Secretary of the Treasury and the Treasurer of the United States, rather than by the President. According to American media reports, the first $100 bills with Trump's signature may be printed as early as June.
"Now Americans will know exactly who to blame as they pay more for groceries, gas, rent, and healthcare," Democratic California Governor Gavin Newsom wrote on social media. ⚠️
#Trump#Bessent#Newsom
👂More on Trump's Ear ⚠️
👨👩👧👦📜SUPREME COURT BLOCKS CALIFORNIA FROM HIDING TRANS KIDS
🔹 Major Ruling: The Supreme Court has struck down California's controversial "Safety Act," which banned schools from forcing teachers to "out" trans kids to parents. 🛑🏳️⚧️
🔹 Parental Rights Win: Validating the concerns of conservative parents nationwide, the court affirmed that schools cannot keep secrets from families about a child's identity. 🏆👨👩👧👦
The battle for the classroom continues. For now, parental notification is the law of the land. California loses again. 🏛️
#SCOTUS#TransRights#ParentalRights#California#Education#Newsom
🏛️🇺🇸SCOTUS STRIKES DOWN CA "SAFETY ACT"
🔹 Supreme Court blocks California law that banned schools from "forced outing" of trans kids to parents 🏳️⚧️
🔹 Major victory for parental rights groups; huge blow to Gavin Newsom"s administration agenda 👨👩👧👦
🔹 Schools can now be required to notify parents if a child changes pronouns or identification 📝
🔹 "Parents have a fundamental right to know," say conservative advocates celebrating the ruling 🗣️
🔹 LGBTQ+ groups call it "shocking" and dangerous for vulnerable student populations ⚠️
California vs The Feds part 500. The culture war in schools just got a lot hotter. 🔥
#SCOTUS#California#TransRights#ParentalRights#Education#Newsom
Finally, we are free from the WHO. In this week's Throwback Thursday, we take a look back at the WHO and everything they've done for us in the name of "health."
https://drtenpenny.substack.com/p/tenpenny-throwback-thursday-4ae
#tenpenny#WHO#gavinnewsom#newsom#rfkjr#throwback
🔹👉🏻@SherriTenpenny
#USA#Senate
Il Governatore della #California Gavin #Newsom (#D|Centro-sinistra) ha nominato l'attivista politica Laphonza #Butler come nuova Senatrice, dopo la scomparsa di Dianne #Feinstein.
Laphonza Butler ha 44 anni, è afroamericana, lesbica e dal 2021 è presidente dell’organizzazione EMILY’s List, che si occupa di promuovere l’elezione di donne Democratiche al #Congress.
@OsservatorioEsteri