TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

57 pointsby pyentropyabout 6 years ago

4 comments

ravabout 6 years ago
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 未加载
enriqutoabout 6 years ago
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 未加载
WoodenChairabout 6 years ago
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.
j88439h84about 6 years ago
Use cffi for calling C.