<br><div class="gmail_quote">On Sat, Aug 27, 2011 at 8:57 PM, Guido van Rossum <span dir="ltr">&lt;<a href="mailto:guido@python.org">guido@python.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Sat, Aug 27, 2011 at 3:14 PM, Dan Stromberg &lt;<a href="mailto:drsalists@gmail.com">drsalists@gmail.com</a>&gt; wrote:<br>
&gt; IMO, we really, really need some common way of accessing C libraries that<br>
&gt; works for all major Python variants.<br>
<br>
</div>We have one. It&#39;s called writing an extension module.<br></blockquote><div><br>And yet Cext&#39;s are full of CPython-isms.<br><br>I&#39;ve said in the past that Python has been lucky in that it had only a single implementation for a long time, but still managed to escape becoming too defined by the idiosyncrasies of that implementation - that&#39;s quite impressive, and is probably our best indication that Python has had leadership with foresight.  In the language proper, I&#39;d say I still believe this, but Cext&#39;s are sadly not a good example.<br>
 </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
ctypes is a crutch because it doesn&#39;t realistically have access to the<br>
header files.</blockquote><div><br>Well, actually, header files are pretty easy to come by.  I bet you&#39;ve installed them yourself many times.  In fact, you&#39;ve probably even automatically brought some of them in via a package management system of one form or another without getting your hands dirty.<br>
<br>As a thought experiment, imagine having a ctypes configuration system that looks around a computer for .h&#39;s and .so&#39;s (etc) with even 25% of the effort expended by GNU autoconf.  Instead of building the results into a bunch of .o&#39;s, the results are saved in a .ct file or something.  If you build-in some reasonable default locations to look in, plus the equivalent of some -I&#39;s and -L&#39;s (and maybe -rpath&#39;s) as needed, you probably end up with a pretty comparable system.<br>
<br>(typedef&#39;s might be a harder problem - that&#39;s particularly worth discussing, IMO - your chance to nip this in the bud with a reasoned explanation why they can&#39;t be handled well!)<br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
 It&#39;s a fine crutch for PyPy, which doesn&#39;t have much of<br>
an alternative.</blockquote><div><br>Wait - a second ago I thought I was to believe that C extension modules were the one true way of interfacing with C code across all major implementations?  Are we perhaps saying that CPython is &quot;the&quot; major implementation, and that we want it to stay that way?<br>
<br>I personally feel that PyPy has arrived as a major implementation.  The backup program I&#39;ve been writing in my spare time runs great on PyPy (and the CPython&#39;s from 2.5.x, and pretty well on Jython).  And PyPy has been maturing very rapidly (&#39;just wish they&#39;d do 3.x!).<br>
<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"> It&#39;s also a fine crutch for people who need something<br>
to run *now*. It&#39;s a horrible strategy for the standard library.<br></blockquote><div><br>I guess I&#39;m coming to see this as dogma.<br><br>If ctypes is augmented with type information and/or version information and where to find things, wouldn&#39;t it Become safe and convenient?  Or do you have other concerns?<br>
<br>Make a list of things that can go wrong with ctypes modules.  Now make a list of things that can wrong with C extension modules.  Aren&#39;t they really pretty similar - missing .so, .so in a weird place, and especially: .so with a changed interface?  C really isn&#39;t a very safe language - not like <a href="http://en.wikipedia.org/wiki/Turing_%28programming_language%29">http://en.wikipedia.org/wiki/Turing_%28programming_language%29</a> or something.  Perhaps it&#39;s a little easier to mess things up with ctypes today (a recompile doesn&#39;t fix, or at least detect, as many problems), but isn&#39;t it at least worth Thinking about how that situation could be improved?<br>
<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
If you have a better proposal please do write it up. But so far you<br>
are mostly exposing your ignorance and insisting dramatically that you<br>
be educated.<font color="#888888"><br></font></blockquote><div><br>I&#39;m not sure why you&#39;re trying to avoid having a discussion.  I think it&#39;s premature to dive into a proposal before getting other people&#39;s thoughts.  Frankly, 100 people tend to think better than one - at least, if the 100 people feel like they can talk.<br>
<br>I&#39;m -not- convinced ctypes are the way forward.  I just want to talk about it - for now.  ctypes have some significant advantages - if we can find a way to eliminate and/or ameliorate their disadvantages, they might be quite a bit nicer than Cext&#39;s.<br>
<br></div></div>