Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
Liberty. Equality. Fraternity.
And don't forget to leave the keys...
Today, TON and Telegram represent a decentralized spaceship with 13 million inhabitants on board, ahead of its time. Cryptocurrency gives many people hope for a free and secure life. Web3 is not just about pixel images and taps; it is also a technology uniting millions of people who today collect coins together and tomorrow could make an important decision for the whole world.
In the few years since TON was established, communities have sprung up around the world—in almost all CIS countries, as well as in Denmark, Italy, Nigeria, Iran, South Korea, Hong Kong... these are just the ones that come to mind because I personally read them. But the community itself is huge and, most importantly, international. It is also very friendly. Just look at the scale of support for Pavel Durov with the ✈️ symbol that hundreds of channels with multimillion audiences simultaneously posted.
I have never encountered racial or religious animosity in TON chats. No one has offered me drugs or weapons. Politics are generally not discussed in crypto communities, except in terms of its impact on the exchange rate. Overall, this is a community of enthusiasts who are eager to learn new things and share their knowledge with others. So, I can confidently say that this is a healthy and sane community.
Against the backdrop of current events, it is worth remembering that the idea around which more than 13 million people worldwide have united is alive and thriving. If all these people lived in one country, that country would rank 75th in population among all the countries in the world. The main idea of the Telegram messenger and TON cryptocurrency is Freedom. Yes, the very freedom that its ideological inspirer Pavel Durov is currently deprived of.
#FreeDurov#TON#Telegram#Liberty
For over 20 years, the US has detained 39 Muslim men at Guantánamo Bay, with 27 never charged. The CIA operated secret "black sites" where at least 119 Muslim men were held and at least 39 tortured, without accountability. This system of unlawful detention, rendition, and abuse has cost billions, fueled propaganda by armed groups, and undermined global human rights.
[Read more]
@googlefactss#HumanRights#Guantanamo#Torture#Accountability#usa#liberty#LandOfTheFree
Trump Calls for Ross Ulbricht's Release
Senator Rand Paul urges President Trump to free Ross Ulbricht, the founder of Silk Road. Meanwhile, Coinbase CEO Brian Armstrong states Trump is excited about a Strategic Bitcoin Reserve, aiming to be the first Bitcoin President. Additionally, Binance's CEO predicts a crypto all-time high in 2025 amid clearer U.S. regulation under Trump. Critical Metals Corp raises $500M for Bitcoin reserve strategy as they accept BTC as treasury asset—first Nasdaq company in critical minerals sector to do so.
🔗 Related articles from Watcher Guru and CoinDesk.
#Bitcoin#USDC#Crypto#Trump#Coinbase#Binance#HesterPeirce#SEC#Decentralization#Finance#Investment#CriticalMetals#Aviation#Regulation#Liberty#Decentralized#Blockchain#CryptoNews#VC
#Bitcoin#USDC#Crypto#Trump#Coinbase#Binance#HesterPeirce#SEC#Decentralization#Finance#Investment#CriticalMetals#Aviation#Regulation#Liberty#Decentralized#Blockchain#CryptoNews#VC
Trump and the American Empire recovery/2
In the grand scheme, reclaiming America’s global dominance is critical to preserving liberty worldwide. Trump’s focus on expanding influence into Greenland, Canada, and the Panama Canal reflects this understanding. By securing these strategic positions, America strengthens its economy, protects vital trade routes, and curtails the growing influence of adversaries. The fight isn’t just about geography—it’s about values.
Trump’s vision recognizes that American strength is a bulwark against tyranny. A strong America doesn’t just serve Americans—it serves the cause of freedom for all.
But the ultimate success of this strategy depends on one thing: vigilance. America must remain true to its founding values of liberty, autonomy, and justice. That means balancing global influence with domestic safeguards, ensuring that while we project strength abroad, we don’t compromise freedom at home. Only then can the American empire thrive as a force for good, outshining authoritarian rivals like China and Russia, and ensuring a world where liberty reigns supreme.
#Canada#Greenland#Denmark#Trump#MAGA#China#Russia#Iran#War#Israel#America#US#USA#Liberty#Freedom#Politics#Panama
Part 1
@KayleighMcEnany