TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Python 3 TSP solver based on LKH (cross platform)

57 点作者 pyentropy将近 6 年前

4 条评论

rav将近 6 年前
Looks like _elkai.c implements a CPython-API function &quot;ElkSolve&quot; that parses the Python lists into a C array, calls a pure-C function &quot;InvokeSolver&quot;, and puts the result of &quot;InvokeSolver&quot; into a Python list.<p>It should be easy to implement &quot;ElkSolve&quot; in pure Python using ctypes to call a pure-C library that exposes the &quot;InvokeSolver&quot; function. That would make it possible to distribute a single Python wheel that works on both Python 2 and 3 and works across all minor versions of Python 3.<p>Currently, elkai works on 3.5, 3.6 and 3.7, but the build system requires a separate build artifact on each, and when Python 3.8 comes out, elkai won&#x27;t be available until the author builds it for 3.8. With a pure-C library, elkai would be immediately available in new Python versions.
评论 #19948722 未加载
enriquto将近 6 年前
I love the &quot;without dependencies&quot; idea. Notice, however, that the algorithm is implemented in C, and it requires (somewhat strangely) cmake to build. I say strangely, because being a C source without dependencies itself, it could be compiled just as easily without cmake.
评论 #19948802 未加载
评论 #19948486 未加载
WoodenChair将近 6 年前
I would think &quot;without dependencies&quot; would mean that this was an original implementation of an algorithm. In fact, this is a wrapper around a C library that someone else did, so I think the title is misleading.
j88439h84将近 6 年前
Use cffi for calling C.