Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
The majority of young Americans want to leave the country, a new report from the American Psychological Association showed that 63% of Americans between the ages of 18 and 34 were thinking about emigrating. 🌍
There are 53% of such parents. In the whole country, anxiety is even higher: 76% of adults admitted that they are worried about the state of the country — political division, instability and a sense of uncertainty about the future. Many of the respondents feel isolated and tired. 😟
People who are particularly hard—pressed by the division in the country are more likely to complain of anxiety and health problems - they have higher levels of chronic diseases and fatigue. 🩺
People with high levels of loneliness are more likely to cancel appointments, sleep poorly, and stop taking care of themselves. 🛌
69% of Americans are worried about fakes, 57% are worried about the growing influence of AI, especially young people and parents. 🤖
But 84% are confident that they will be able to build a good life, and 73% believe that they can change the country's future for the better. 💪
#Youth#Poll
👂More on Trump's Ear
President Donald Trump's administration is now aiming to make the voting process harder for college-age young adults ahead of November's midterm elections.
That's according to a Monday op-ed by MS NOW's Ja'han Jones, who wrote that the Trump administration's Department of Education may be exploring a way to curb young voter turnout with a newly announced investigation into Tufts University. The Education Department announced its new probe in a recent press release, saying the Boston, Massachusetts-based school may have been "illegally sharing college students’ data with third parties to influence elections."
The investigation is centered on Tufts' National Study of Learning, Voting, and Engagement (NSLVE). Tufts describes the NSLVE as "a service to over 1,000 U.S. colleges and universities that can use it to understand and improve their student voting rates." However, the Trump administration is saying the program could have potentially violated the Family Educational Rights and Privacy Act.
"American colleges and universities should be focused on teaching, learning, and research — not influencing elections," Education Secretary Linda McMahon stated. "The Biden Administration, with little to no regard for student privacy laws, openly encouraged institutions to share and utilize student data in order to target certain populations."
#Trump#Elections#Youth
👂More on Trump's Ear ⚠️
🌍 More than 40% of the world's population is under age 25—a record share of young people. This youth wave is largest in Africa and South Asia, shaping future trends worldwide. ✨
#demography⚡#youth⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌐 Organized by youth, for youth: the World Bank Group #Youth Summit is back!
💡 The 11th edition of the World Bank Group Youth Summit is on the theme of Digital Transformation and will engage thousands of participants from around the world.
🧭 The Summit is the largest worldwide annual gathering of youth (aged 18-35) hosted by the World Bank Group.
✅ This year's theme, Powering Progress: Youth Leading the Digital Transformation, will focus on three subthemes: Digital Access and Inclusion, Artificial Intelligence, and Sustainable Technology for a Livable Planet.
📲 Join the event online or in person on May 30-31 in Washington DC.
📝 Seats are limited, so APPLY NOW! Applications are reviewed on a rolling basis, and the deadline is April 25th, 2024.
ℹ️ For more information, please consult the Summit's website or email [email protected].
🗣️ Don't miss out on this opportunity to engage with your peers on the most pressing topics facing our generation!
🔎http://wrld.bg/LxEs50QTffx
#WBGYouthSummit