arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2504.04302cs.PLcs.DS
收藏

AbsInf:在Dijkstra算法中表示float('inf')的轻量级对象

AbsInf: A Lightweight Object to Represent float('inf') in Dijkstra's Algorithm

Anjan Bellamkonda, Laksh Bharani, Harivatsan Selvam

AI总结:

本文提出轻量级抽象对象AbsInf,作为Python中float('inf')的高性能替代,通过基于C的扩展绕过浮点强制转换与动态分派,在Dijkstra算法中实现常数时间比较,使运行时间平均减少9.74%。

摘要:

我们引入了AbsInf,这是一种轻量级抽象对象,旨在作为寻路算法中Python原生float('inf')的高性能替代方案。AbsInf作为基于C的Python扩展实现,绕过了IEEE-754浮点数强制转换和动态类型分派,提供常数时间的支配比较和算术中立性。在不改变逻辑的情况下将其集成到Dijkstra算法中时,AbsInf使运行时间减少了17.2%,在多样化的合成和真实图数据集上平均减少9.74%。这一优化突显了高频算法构造中的性能权衡,其中对无穷大的符号化使用允许了高效的抽象。我们的发现为解释型语言的轻量级架构增强的更广泛讨论做出了贡献,特别是在性能关键的控制流中。

英文摘要:

We introduce AbsInf, a lightweight abstract object designed as a high-performance alternative to Python's native float('inf') within pathfinding algorithms. Implemented as a C-based Python extension, AbsInf bypasses IEEE-754 float coercion and dynamic type dispatch, offering constant-time dominance comparisons and arithmetic neutrality. When integrated into Dijkstra's algorithm without altering its logic, AbsInf reduces runtime by up to 17.2%, averaging 9.74% across diverse synthetic and real-world graph datasets. This optimization highlights the performance trade-offs in high-frequency algorithmic constructs, where a symbolic use of infinity permits efficient abstraction. Our findings contribute to the broader discourse on lightweight architectural enhancements for interpreted languages, particularly in performance-critical control flows.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑