Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
👀Educational content, charity and newcomer-friendly tools: An insightful look into the inner workings of a global crypto exchange.
🛡Learn how BingX diverse trading options can help you manage risks and capitalize on opportunities.
#DigitalCurrency
#Cryptonews
#CryptoCommunity
#Cryptolife
🚀 Iran Utilizes Cryptocurrency for Strait of Hormuz Passage Fees
Iran is employing cryptocurrency to collect fees from ships passing through the Strait of Hormuz. According to NS3.AI, TRM highlighted that the rapid nature of digital currency transactions and their operation outside the U.S. banking system complicate efforts by the U.S. to freeze or block these payments in real time.
#Iran#Cryptocurrency#StraitOfHormuz#DigitalCurrency#Shipping#USSanctions#Blockchain
Massachusetts to Establish Bitcoin Reserve
Massachusetts Senator Peter Durant proposes a bill to create a Strategic Bitcoin Reserve. This aligns with initiatives in states like Oklahoma, Wyoming, and Ohio, driving a potential federal reserve plan via executive orders or legislative action. Full details here: Blockspace
#Bitcoin#Crypto#Blockchain#Finance#Investment#Legislation#DigitalCurrency#Innovation#Massachusetts#UTC VC
🚀 Quantum Safe Bitcoin Proposed to Resist Quantum Attacks
Avihu Levy has introduced a concept called Quantum Safe Bitcoin, which is a hash-based transaction design intended to withstand quantum computing attacks. According to NS3.AI, this proposal seeks to enhance Bitcoin's security without altering its fundamental rules. The estimated cost for implementing this design using cloud GPU computing ranges from $75 to $150. However, the complete transaction assembly and broadcast have yet to be demonstrated on the blockchain.
#QuantumSafeBitcoin#Bitcoin#QuantumComputing#Blockchain#Cryptocurrency#CyberSecurity#DigitalCurrency#CryptoInnovation#BTC
🚀 AI TRENDS | Xverse Launches AI-Driven Bitcoin Wallet for Enhanced Transactions
Bitcoin wallet Xverse has announced the introduction of its AI-powered Agentic Wallet, designed to facilitate payments, transactions, and fund management on the Bitcoin network. According to Foresight News, the wallet utilizes Spark for lightning payments and supports machine-payable APIs through MPP, featuring a fully self-custodial architecture.
#AI#Bitcoin#Cryptocurrency#Fintech#Wallet#Blockchain#Payments#MachineLearning#DigitalCurrency#BTC
🚀 Solana Developer Platform Launches Amid Growing Interest in Stablecoin Settlement
The Solana Foundation has introduced its Solana Developer Platform, marking a significant milestone for the network as it reaches 167 million monthly token holders. According to NS3.AI, this development comes as major financial entities like Mastercard are investigating stablecoin settlement on the Solana blockchain. Additionally, Worldpay and Western Union are exploring on-chain settlement and cross-border transfer capabilities.
In a related move, MetaMask has announced that its MetaMask Card now allows American users to spend Solana USDC at any location where Mastercard is accepted. This expansion of services highlights the increasing integration of Solana's blockchain technology into mainstream financial systems.
#Solana#Blockchain#Stablecoin#Crypto#DeFi#MetaMask#USDC#Fintech#CrossBorderPayments#DigitalCurrency#SOL
🚀 Russia Implements Full Ban on Crypto-to-Cash Exchanges
Russia has enacted a comprehensive ban on crypto-to-cash exchanges, marking a significant policy development in the region. According to NS3.AI, this move is part of a broader trend of regulatory changes across Asia, as countries continue to refine their approaches to cryptocurrency regulation. The ban is expected to impact the way digital currencies are traded and used within Russia, potentially influencing other nations in the region to adopt similar measures. This development is one of several key policy shifts observed in Asia this week, highlighting the evolving landscape of cryptocurrency regulation.
#Russia#Cryptocurrency#CryptoRegulation#CryptoBan#DigitalCurrency#Asia#PolicyChange
Avalanche Visa Card Launches Today
Avalanche has officially launched its Visa card to promote cryptocurrency adoption. The card allows users to spend crypto easily in daily transactions, integrating DeFi solutions. This move aims to bridge the gap between traditional finance and the digital currency landscape, enhancing user accessibility to crypto assets. Read more here.
#Avalanche#Crypto#DeFi#Visa#Blockchain#Finance#MassAdoption#Payments#DigitalCurrency
🚀 Swiss Banks Launch Sandbox for Franc-Pegged Stablecoin Testing
Six Swiss banks, in collaboration with Swiss Stablecoin AG, have initiated a sandbox project for a stablecoin pegged to the Swiss franc, set to operate until 2026. According to NS3.AI, the test involves an ERC-20 token on the Ethereum blockchain and will be conducted in a controlled live environment with transaction limits and a restricted participant pool. While the specific access terms and use cases have not been disclosed, an interim report is anticipated in the second half of the year.
#Switzerland#Banks#Stablecoin#Cryptocurrency#Blockchain#Ethereum#FinTech#DigitalCurrency#Sandbox#Finance#ETH
🚀 Authorities Freeze $12 Million in Cryptocurrency Crime Proceeds
Authorities from the United States, the United Kingdom, and Canada have collaborated in a cross-border operation to freeze $12 million in proceeds from cryptocurrency-related crimes. According to NS3.AI, the investigation specifically targeted phishing schemes, highlighting the ongoing efforts to combat cybercrime in the digital currency sector.
#cryptocurrency#cybercrime#phishing#lawenforcement#crossborder#digitalcurrency#crimeproceeds#NS3AI