<div dir="auto">Dear Krishna <div dir="auto"><br></div><div dir="auto">Many thanks for your detailed analysis. We will keep you posted about how we advance in this endeavor. </div><div dir="auto"><br></div><div dir="auto">Esteban </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 14, 2022, 19:29 Krishna Chaitanya <<a href="mailto:bkchaitan94@gmail.com">bkchaitan94@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Dear Professor,</div><div><br></div><div>I must say it's been a while since I worked with Python/C bindings, for PyMEOS, I looked more in the C++/Python direction.</div><div>Anyways, from what I remember these the main pros/cons of each:</div><div><br></div><div><b>ctypes</b></div><div>This is generally the recommended way to go. And most libraries are built in this approach.</div><div>It is the simplest to understand for people coming mainly from C background.</div><div>It is a bit tedious and repetitive work to build interfaces in ctypes compared to other approaches, where some of the boring parts are a bit automated (although at the cost performance overhead and/or learning curve).<br></div><div><br></div><div><b>CFFI</b></div><div>This seems to be the newer alternative to ctypes, I haven't explored it in detail much before.<br></div><div><br></div><div><b><span><span>Cython</span></span></b></div><div><span><span>This is the easier approach. It's a bit higher level than ctypes and CFFI. It has an intermediate language between python and c through which the interfacing happens.<br></span></span></div><div><span><span>Shapely was built using Cython. Although performance wise, it is usually said that this approach has some overhead compared to other approaches.<br></span></span></div><div><br></div><div><b>C extension module</b></div><div>This is the lowest level interfacing possible and possibly the performant. But disadvantage is it would only support developers using the CPython compiler. While that covers the majority, some people who use PyPy, jPython etc might not be able to use the library.</div><div>Another advantage here is that when dealing with Python data science tools like numpy and pandas, you can make operations that work on a collection of objects faster by utilizing <a href="https://numpy.org/devdocs/user/c-info.ufunc-tutorial.html" target="_blank" rel="noreferrer">ufuncs from numpy</a>. This is the approach taken by the library <a href="https://github.com/pygeos/pygeos" target="_blank" rel="noreferrer">pygeos</a>, which is now merged into Shapely.</div><div><br></div><div>In conclusion, I wouldn't say there is any best approach, I think any option is good. If at all I had to pick an option, maybe I would just go with either of ctypes/CFFI approaches to start off and to keep it simple and balanced for performance.</div><div>Hope that helps. Do let me know if you need anything more.<br></div><div><br></div><div>Thanks,</div><div>Krishna Chaitanya<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 13 Jun 2022 at 17:53, Esteban Zimanyi <<a href="mailto:estebanzimanyi@gmail.com" target="_blank" rel="noreferrer">estebanzimanyi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear Krishna</div><div><br></div><div>Allow me one quick question. I am discovering the world of Python bindings, e.g.,</div><a href="https://realpython.com/python-bindings-overview/" target="_blank" rel="noreferrer">https://realpython.com/python-bindings-overview/</a><div><br></div><div>My approach would be to link the libmeos C library to MobilityDB-python</div><div><a href="https://github.com/MobilityDB/MobilityDB-python" target="_blank" rel="noreferrer">https://github.com/MobilityDB/MobilityDB-python</a></div><div><br></div><div>Which approach do you recommend ? ctypes, CFF, Cython, other ?</div><div><br></div><div>Thanks again for you insights</div><div><br></div><div>Esteban</div><div><br clear="all"><div><div dir="ltr"><div dir="ltr"><div>------------------------------------------------------------<br>Prof. Esteban Zimanyi<br>Department of Computer & Decision Engineering  (CoDE) CP 165/15    <br>Universite Libre de Bruxelles            <br>Avenue F. D. Roosevelt 50                <br>B-1050 Brussels, Belgium                 <br>fax: + 32.2.650.47.13<br>tel: + 32.2.650.31.85<br>e-mail: <a href="mailto:esteban.zimanyi@ulb.be" target="_blank" rel="noreferrer">esteban.zimanyi@ulb.be</a><br>Internet: <a href="http://cs.ulb.ac.be/members/esteban/" target="_blank" rel="noreferrer">http://cs.ulb.ac.be/members/esteban/</a><br>------------------------------------------------------------</div></div></div></div></div></div>
</blockquote></div>
</blockquote></div>