Filter
Exclude
Time range
-
Near
github.com/CodeNightOwl/delp… Delphi-Python 共享内存双向微秒级通信项目 开发动机 Python 和 Golang 在界面开发方面存在明显短板,而对于普通用户而言,要求其配置环境、使用命令行操作是反人类的体验——正常的解决方案应该是直接交付可执行的 EXE 文件,所以我们可以python来开发功能,Delphi来开发界面(还可以动态执行python脚本)。 Delphi 能够在短时间内开发出大型 ERP 系统界面,更不用说小型工具了。尽管常被认为是一门"过时"的语言,主要依靠销售 IDE 盈利,但它仍能长期稳居编程语言排行榜前十左右。 设计思路可扩展到其他语言组合,选择 Python 是因为其生态丰富(例如需要对接 150 个交易所通讯的场景,无需重复造轮子),ai编程对他来说支持也是最好的,Delphi这种依赖IDE又稍偏门的语言你用Ai跑一个晚上早上醒来他执行几百次都不对的时候,可能自己几分钟写出来了。 因为我现在需要做高频交易,所以对延迟有严格的要求,不说需要多快,只能说能快就快。 性能要求 微秒级通信延迟是针对高频交易场景的硬性需求,需要实时响应和处理交易指令。Delphi 自身能够实现 C 语言的性能,部分核心模块也可直接用 Delphi 开发。 独立运行 用Python4Delphi 虽然能执行python脚本,但独立性不足,且 Python 的版本管理和包依赖处理较为复杂。而本方案中: Python 端打包为独立 EXE Delphi 端编译为独立 EXE 除通信接口外,双方完全隔离开发,无耦合依赖 Delphi 通过创建进程方式启动 Python 可执行文件(如将 Python EXE 嵌入 Delphi 资源,则可实现单文件部署) 传输协议性能对比 通信方式典型延迟RESTful API5-10msWebSocket约 5msgRPC约 3mszeroMq毫秒级(如果局域网可选择)命名管道毫秒级共享内存微秒级 核心技术要点 序列化选择 重要提示:切勿使用 JSON 进行数据传输!切勿使用 JSON 进行数据传输!切勿使用 JSON 进行数据传输! JSON 的编码解码效率极低,使用后将无法实现微秒级性能,毫秒级保证不了。 MessagePack 采用二进制序列化,效率显著更高。对于交易所 API 通常使用 JSON 的情况,Python 的字典结构天然兼容 JSON 和 MessagePack,我们只需在传输时进行一次序列化转换即可。 性能优化: Python 的 JSON 序列化使用 orjson(底层由 Rust 实现,效率极高) Python 的 MsgPack 序列化使用 (底层由 C 实现 ) 可突破 GIL限制,结合语言特性实现极致速度 双向通信机制 Python → Delphi 方向 Python 向 Python 写区(PYTHON_WRITE_OFFSET)写入数据 Python 发送通知给 Delphi Delphi 从 Python 写区(PYTHON_WRITE_OFFSET)读取数据 Delphi → Python 方向 Delphi 向 Delphi 写区(DELPHI_WRITE_OFFSET)写入数据 Delphi 发送通知给 Python Python 从 Delphi 写区(DELPHI_WRITE_OFFSET)读取数据 系统架构特点 共享内存双向通信 事件通知 MessagePack 封装 线程池优先级执行任务,专为高速数据交换场景优化设计。 技术优势 极致性能:基于 Windows 共享内存,彻底消除网络延迟 全双工通信:Delphi 和 Python 可同时互相发送和接收数据,支持实时事件通知 低延迟响应:微秒级响应时间,基于事件驱动机制 共享内存设计 总内存大小:400MB(可根据实际需求调整) 分区策略:Python 写区:0-199MB(200MB 容量) Delphi 写区:200-399MB(200MB 容量) 编码格式:MsgPack 二进制序列化 事件通知:基于 Windows 事件对象的双向通知机制 消息格式:4 字节消息长度头 MsgPack 序列化数据 线程池设计 线程数:根据 CPU 核心数动态调整(默认值为核心数) 任务队列:无界队列,支持高并发任务提交 任务优先级:根据任务类型(如实时事件、普通消息)分配不同优先级,确保关键任务及时处理 项目编译 Delphi:使用 Delphi 10.3 或更高版本编译 Python:使用 Python 3.10 或更高版本编译 测试程序 启动 Python 端 main.py (必须先启动) 启动 Delphi 端 启动 发送给delphi队列性能验证.py 可以测试批量发送给delphi的性能 点击 delphi 界面按钮,发送给main.py的消息,main.py会收到并打印在控制台上 视频中python端提示“网络延迟” 是笔误,内存通讯,没有网络, 时间是内存写入 事件通知 messagePack解包的总时间。 #web3 #meme
3
1,355
🚀 Tornano le live di coding su #Twitch! 🎉 Martedì 3 settembre alle 21.30 esploreremo la combinazione micidiale di #Delphi 🏛️ #Python 🐍 con #Python4Delphi! Scriviamo codice, ci divertiamo e lanciamo meme nerd! 😂 Iscriviti qui: twitch.tv/compilaquindiva. E' aperta a tutti! 💘
2
5
150
19 Feb 2024
In Delphi there's an open source package named Python4Delphi, that allows you to bridge the strengths of Delphi with the vast amount of libraries in Python. There are also Python GUI libraries wrapping the VCL and FMX frameworks if you so desire.
2
34
28 Jul 2023
Python integrates well into the moder #Delphi Object Pascal ecosystem through the Python4Delphi package. Once you've become more comfortable with Python, I'd highly recommend to check out #Delphi too 🙂
1
3
110
Python4Delphi: from Zero to Hero #itdevcon #replay youtube.com/watch?v=zcM5gecy…

2
2
126
@danieleteti ci mostra come utilizzare efficacemente #python4delphi nella nostra applicazione #Delphi. @bittimepro youtu.be/zcM5gecyrxU

2
2
105
Replying to @AdamChainz
What about using #Delphi together with the Python4Delphi project? 🙂
1
3
56
The latest update in the Delphi-Python ecosystem includes: compiling Python4Delphi for #Linux, updated installation tutorials, and backward compatibility of PythonEnvironments to #Delphi Sydney (10.4). Read more: embt.co/3VtZZF4 #developers #tools #programming
1
12
With @JimMcKeeth at #itdevcon. Talking about Python4Delphi
2
8
در این پست به معرفی ۵ ابزار یا فریمورک برای برنامه نویسی اپلیکیشن های تحت دسکتاپ با زبان برنامه نویسی پایتون میپردازیم. در لیست زیر این ۵ ابزار محبوب را میبینید ‌ 1. Python4Delphi (P4D) 2. PyQT 3. Tkinter 4. Kivy 5. PyGUI مقاله کامل :‌ avasam.ir/post/407/س…
3
Python4Delphi Brief Overview for Delphi and Python Developers x.com/i/broadcasts/1vOxwMljP…

1
5
Getting Started with Python4Delphi x.com/i/broadcasts/1BRJjZzPO…

4
Replying to @willmcgugan
The GUI packages: delphifmx and delphivcl. We're bringing the mature GUI packages from Delphi(object pascal) to Python. We're building whole ecosystem around Delphi and Python. People can start to build extension modules using Delphi instead of C/C using Python4Delphi bridge.
1
1
2
In 15 minutes, join Kiriakos Vlahos in the "Python4Delphi: Using Python for Delphi Developers" session at 4 pm CDT. Register to watch: hhttps://embt.co/3dpiyJm #learntocode #programming #coding #CodingBootCamp2022
4
7
16 Mar 2022
Fun fact, #Delphi is still going strong and become really powerful! There's a nice Python4Delphi integration so you can combine the best of both worlds and both the Delphi VCL and FMX UI frameworks have been released as Python modules for better UI work with Python.
1
A new #Delphi book from Dr. Kevin R. Bond is out! This book shows how to program the #Arduino microcontroller in Delphi to monitor the temperature. #Python4Delphi and anonymous functions are also covered. Check it out: ow.ly/Z4wZ50H5Cu6

1
1
5
Through #Python4Delphi, Delphi #developers can leverage the entire collection of Python libraries directly from their favorite #IDE. Here are our 10 top How-Tos for combining the two languages: embt.co/3qL2Pci #Delphi #Python embt.co/3Foed1I
1
4
4
30 Sep 2021
Delphi 11 Alexandria の GetIt に Python4Delphi が来てます。
29 Sep 2021
Hey #Delphi community! Python4Delphi now can be installed from #GetIt. Try #Python libraries functionality with #Delphi #VCL and #FMX #GUI!
1
1
4