TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #241 · 5 мај

Можно ли в Python создавать бинарные файлы? Конечно можно. Для этого в Python есть следующие инструменты: ▫️ тип данных bytes и bytearray ▫️ открытие файла в режиме wb (write binary) или rb (read binary) ▫️ модуль struct Про модуль struct поговорим в первую очередь. Файл в формате JSON или Yaml внутри себя содержит разметку данных. Всегда можно определить где список начался а где закончился. Где записана строка а где словарь. То есть формат записи данных содержит в себе элементы разметки данных. В binary-файле данные не имеют визуальной разметки. Это просто байты, записанные один за другим. Правила записи и чтения находятся вне файла. Модуль struct как раз и помогает с организацией данных в таком файле с помощью определения форматов записи для разных частей файла. Модуль struct преобразует Python-объекты в массив байт, готовый к записи в файл и имеющий определённый вид. Для этого всегда следует указывать формат преобразования (или, как оно здесь называется - запаковки). Формат нужен для того, чтобы выделить достаточное количество байт для записи конкретного типа объекта. В последствии с помощью того же формата будет производиться чтение. При этом следует помнить что мы говорим о типах языка С а не Python. Именно формат определяет, что записано в конкретном месте файла, число, строка или что-то еще. Вот какие токены формата у нас есть. Помимо этого, первым символом можно указать порядок байтов. На разных системах одни и те же типы данных могут записываться по-разному, поэтому желательно указать конкретный способ из доступных. Если этого не сделать, то используется символ '@', то есть нативный для текущей системы. В строке формата мы пишем в каком порядке и какие типы собираемся преобразовать в байты. Запакуем в байты простое число, токен "i". >>> import struct >>> struct.pack('=i', 10) b'\n\x00\x00\x00' Теперь несколько float, при этом нужно передавать элементы не массивом а последовательностью аргументов. >>> struct.pack('=fff', 1.0, 2.5, 4.1) b'\x00\x00\x80?\x00\x00 @33\x83@' Вместо нескольких токенов можно просто указать нужное количество элементов перед одним токеном, результат будет тот же. >>> struct.pack('=3f', 1.0, 2.5, 4.1) b'\x00\x00\x80?\x00\x00 @33\x83@' Теперь запакуем разные типы >>> data = struct.pack('=fiQ', 1.0, 4, 100500) я запаковал типы float, int и unsigned long long (очень большой int, на 8 байт) b'\x00\x00\x80?\x04\x00\x00...' Распаковка происходит аналогично, но нужно указать тот же формат, который использовался при запаковке. Результат возвращается всегда в виде кортежа. >>> struct.unpack('=fiQ', data) (1.0, 4, 100500) Как видите, ничего страшного! #lib#basic

Hashtags

Резултати

Пронајдени 8 слични објави

Пребарај: #wasm

当前筛选 #wasm清除筛选
GitHub Trends

@githubtrending · Post #14675 · 06.05.2025 г., 11:30

#rust#consensus_protocol#cryptocurrency#rust#wasm Kaspa's Rust implementation boosts speed and security, allowing faster transactions (up to 10 blocks per second) while maintaining decentralization. The recent Crescendo upgrade enhances performance, and the code is open for collaboration, offering a reliable, efficient system for users to transact quickly and securely. https://github.com/kaspanet/rusty-kaspa

✈️ MapPoster Online | 把一座城市做成可打印海报 🏷 检索标签:#MapPosterOnline#地图海报#OpenStreetMap#WASM#Rust#城市地图 ⭐️ 详情介绍:MapPoster Online 是个在线城市地图海报工具,选城市后就在浏览器里出图。它能导出 A4、方图、手机壁纸、16:9格式,印刷图的话支持到 300 DPI;旅行地、家乡、常去城市都能拿来做纪念图 20 个主题里有北欧、霓虹、航海、故障紫,背景、道路、水体和字色都能自己调。Rust/WASM 渲染加本地缓存,重做时少等一截 🔎MapPoster在线体验 📖GitHub 📜相关阅读: 🔘City Map Poster Generator | 17 种风格的城市地图生成器,把喜欢的城市变成一张可以挂墙的地图作品 😌频道 |🙂群聊 |😋中文包 |☺️搜索

GitHub Trends

@githubtrending · Post #14959 · 14.07.2025 г., 13:00

#javascript#cheerp#cheerpx#cpp#lwip#repl#tailscale#vm#wasm#webassembly#webvm#xterm_js WebVM lets you run a full Linux system directly in your web browser without needing a server. It uses a special engine called CheerpX to safely run unmodified Linux programs by converting x86 code to WebAssembly. You get a real Debian Linux environment with many tools, and it supports networking through Tailscale VPN, so your browser VM can connect securely to the internet. You can also customize and deploy your own WebVM easily using GitHub, making it great for development, testing, or learning Linux without installing anything. This means you can have a powerful, private Linux machine anytime, anywhere, just in your browser[1][2][3]. https://github.com/leaningtech/webvm

GitHub Trends

@githubtrending · Post #14682 · 07.05.2025 г., 13:30

#kotlin#android#awt#compose#declarative_ui#desktop#gui#ios#javascript#kotlin#multiplatform#reactive#swing#ui#wasm#web#webassembly Compose Multiplatform is a Kotlin-based framework by JetBrains that lets you build user interfaces for multiple platforms—iOS, Android, desktop (Windows, macOS, Linux), and web—using mostly shared code. It is based on Jetpack Compose for Android, so you can use similar APIs across platforms, speeding up development and ensuring consistent UI design. iOS support is in beta, web is in alpha, and desktop and Android are stable. You can also access native features like camera or maps easily. This helps you save time, reduce bugs, and create apps that work well everywhere with less effort. https://github.com/JetBrains/compose-multiplatform

GitHub Trends

@githubtrending · Post #14824 · 12.06.2025 г., 12:00

#typescript#3d#browser_based#cad#geometry#occ#occt#opencascade#three#threejs#wasm#webassembly#webcad Chili3D is a free, open-source 3D CAD application that you can use directly in your web browser. It allows you to create and edit 3D models without needing to install any software on your computer. You can make basic shapes like boxes and spheres, draw 2D sketches, and perform advanced operations like combining shapes. It also includes tools for precise alignment and measurement. This makes it easy for anyone to design and edit 3D models online, which is helpful for both beginners and experienced users. https://github.com/xiangechen/chili3d

GitHub Trends

@githubtrending · Post #14969 · 17.07.2025 г., 11:30

#cplusplus#artificial_intelligence#cloud#cloud_native#cncf#container#docker#edge_computing#ewasm#hacktoberfest#hacktoberfest2023#kubernetes#rust_lang#serverless#wasm#webassembly WasmEdge is a fast, lightweight, and secure WebAssembly runtime that lets you run programs safely on your devices, servers, or the cloud. It supports many programming languages like C++, Rust, and JavaScript, and can run AI models, microservices, and smart contracts efficiently. WasmEdge offers strong security by isolating programs, making it great for extending software safely. It works well on edge devices, smart devices, and cloud environments, and supports easy integration with tools like Kubernetes and Docker. Using WasmEdge helps you run powerful applications faster, safer, and more flexibly on various platforms[1][2][3][4][5]. https://github.com/WasmEdge/WasmEdge

GitHub Trends

@githubtrending · Post #15518 · 24.02.2026 г., 11:30

#rust#ai#ai_ocr#attention_mechanism#gnn#gnn_model#gnns#graph#graph_neural_networks#llm_inference#low_latency#mincut#neo4j#ocr#onnx#rust#vector#wasm RuVector is a free, open-source vector database that gets smarter with every query. Unlike static databases, it learns from usage via GNN layers, runs LLMs locally with no cloud costs, supports graph queries like Neo4j, scales freely across nodes, and deploys as a single self-booting file (125ms startup). Run with `npx ruvector`. You benefit from faster, more accurate AI search that improves automatically, zero operating costs, full offline/privacy control, and easy scaling—perfect for RAG, agents, or edge apps without vendor lock-in. https://github.com/ruvnet/ruvector

GitHub Trends

@githubtrending · Post #14788 · 05.06.2025 г., 00:00

#cplusplus#avx#avx_512#avx_instructions#avx2#avx512#intrinsics#neon#simd#simd_instructions#simd_intrinsics#simd_library#simd_parallelism#simd_programming#sse42#wasm Highway is a C++ library that helps make software run faster and use less energy. It does this by using SIMD (Single Instruction, Multiple Data) instructions, which let the CPU perform the same operation on many pieces of data at once. This can make programs up to 10 times faster and reduce energy use by up to five times. Highway works on many different types of computers and is easy to use, making it a good choice for developers who want to improve their software's performance. https://github.com/google/highway