-cc: python-3000<br><br>I believe those APIs are already there in the existing interface.&nbsp; Why does that concern you?<br><br><div class="gmail_quote">On Mon, Jun 2, 2008 at 9:17 AM, Lisandro Dalcin &lt;<a href="mailto:dalcinl@gmail.com">dalcinl@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Are you completelly sure of adding those guys: &nbsp;PyBytes_InternXXX ???<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
On 6/1/08, Gregory P. Smith &lt;<a href="mailto:greg@krypto.org">greg@krypto.org</a>&gt; wrote:<br>
&gt; On Fri, May 30, 2008 at 1:37 AM, M.-A. Lemburg &lt;<a href="mailto:mal@egenix.com">mal@egenix.com</a>&gt; wrote:<br>
&gt; &nbsp;&gt; On 2008-05-30 00:57, Nick Coghlan wrote:<br>
&gt; &nbsp;&gt;&gt;<br>
&gt; &nbsp;&gt;&gt; M.-A. Lemburg wrote:<br>
&gt; &nbsp;&gt;&gt;&gt;<br>
&gt; &nbsp;&gt;&gt;&gt; * Why can&#39;t we have both PyString *and* PyBytes exposed in 2.x,<br>
&gt; &nbsp;&gt;&gt;&gt; with one redirecting to the other ?<br>
&gt; &nbsp;&gt;&gt;<br>
&gt; &nbsp;&gt;&gt; We do have that - the PyString_* names still work perfectly fine in 2.x.<br>
&gt; &nbsp;&gt;&gt; They just won&#39;t be used in the Python core codebase anymore - everything in<br>
&gt; &nbsp;&gt;&gt; the Python core will use either PyBytes_* or PyUnicode_* regardless of which<br>
&gt; &nbsp;&gt;&gt; branch (2.x or 3.x) you&#39;re working on. I think that&#39;s a good thing for ease<br>
&gt; &nbsp;&gt;&gt; of maintenance in the future, even if it takes people a while to get their<br>
&gt; &nbsp;&gt;&gt; heads around it right now.<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; Sorry, I probably wasn&#39;t clear enough:<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; Why can&#39;t we have both PyString *and* PyBytes exposed as C<br>
&gt; &nbsp;&gt; APIs (ie. visible in code and in the linker) in 2.x, with one redirecting<br>
&gt; &nbsp;&gt; to the other ?<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt;&gt;&gt; * Why should the 2.x code base turn to hacks, just because 3.x wants<br>
&gt; &nbsp;&gt;&gt;&gt; to restructure itself ?<br>
&gt; &nbsp;&gt;&gt;<br>
&gt; &nbsp;&gt;&gt; With the better explanation from Greg of what the checked in approach<br>
&gt; &nbsp;&gt;&gt; achieves (i.e. preserving exact ABI compatibility for PyString_*, while<br>
&gt; &nbsp;&gt;&gt; allowing PyBytes_* to be used at the source code level), I don&#39;t see what<br>
&gt; &nbsp;&gt;&gt; has been done as being any more of a hack than the possibly more common<br>
&gt; &nbsp;&gt;&gt; &quot;#define &lt;oldname&gt; &lt;newname&gt;&quot; (which *would* break binary compatibility).<br>
&gt; &nbsp;&gt;&gt;<br>
&gt; &nbsp;&gt;&gt; The only things that I think would tidy it up further would be to:<br>
&gt; &nbsp;&gt;&gt; - include an explanation of the approach and its effects on API and ABI<br>
&gt; &nbsp;&gt;&gt; backward and forward compatibility within 2.x and between 2.x and 3.x in<br>
&gt; &nbsp;&gt;&gt; stringobject.h<br>
&gt; &nbsp;&gt;&gt; - expose the PyBytes_* functions to the linker in 2.6 as well as 3.0<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; Which is what I was suggesting all along; sorry if I wasn&#39;t<br>
&gt; &nbsp;&gt; clear enough on that.<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; The standard approach is that you provide #define redirects from the<br>
&gt; &nbsp;&gt; old APIs to the new ones (which are then picked up by the compiler)<br>
&gt; &nbsp;&gt; *and* add function wrappers to the same affect (to make linkers,<br>
&gt; &nbsp;&gt; dynamic load APIs such ctypes and debuggers happy).<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; Example from pythonrun.h|c:<br>
&gt; &nbsp;&gt; ---------------------------<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; /* Use macros for a bunch of old variants */<br>
&gt; &nbsp;&gt; #define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; /* Deprecated C API functions still provided for binary compatiblity */<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; #undef PyRun_String<br>
&gt; &nbsp;&gt; PyAPI_FUNC(PyObject *)<br>
&gt; &nbsp;&gt; PyRun_String(const char *str, int s, PyObject *g, PyObject *l)<br>
&gt; &nbsp;&gt; {<br>
&gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp; &nbsp;return PyRun_StringFlags(str, s, g, l, NULL);<br>
&gt; &nbsp;&gt; }<br>
&gt; &nbsp;&gt;<br>
&gt;<br>
&gt;<br>
&gt; Okay, how about this? &nbsp;<a href="http://codereview.appspot.com/1521" target="_blank">http://codereview.appspot.com/1521</a><br>
&gt;<br>
&gt; &nbsp;Using that patch, both PyString_ and PyBytes_ APIs are available using<br>
&gt; &nbsp;function stubs similar to the above. &nbsp;I opted to define the stub<br>
&gt; &nbsp;functions right next to the ones they were stubbing rather than<br>
&gt; &nbsp;putting them all at the end of the file or in another file but they<br>
&gt; &nbsp;could be moved if someone doesn&#39;t like them that way.<br>
&gt;<br>
&gt;<br>
&gt; &nbsp;&gt; I still believe that we should *not* make &quot;easy of merging&quot; the<br>
&gt; &nbsp;&gt; primary motivation for backporting changes in 3.x to 2.x. Software<br>
&gt; &nbsp;&gt; design should not be guided by restrictions in the tool chain,<br>
&gt; &nbsp;&gt; if not absolutely necessary.<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; The main argument for a backport needs to be general usefulness<br>
&gt; &nbsp;&gt; to the 2.x users, IMHO... just like any other feature that<br>
&gt; &nbsp;&gt; makes it into 2.x.<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; If merging is difficult then this needs to be addressed, but<br>
&gt; &nbsp;&gt; there are more options to that than always going back to the<br>
&gt; &nbsp;&gt; original 2.x trunk code. I&#39;ve given a few suggestions on how<br>
&gt; &nbsp;&gt; this could be approached in other emails on this thread.<br>
&gt;<br>
&gt;<br>
&gt; I am not the one doing the merging or working on merge tools so I&#39;ll<br>
&gt; &nbsp;leave this up to those that are.<br>
&gt;<br>
&gt; &nbsp;-gps<br>
</div></div>&gt; &nbsp;_______________________________________________<br>
&gt; &nbsp;Python-Dev mailing list<br>
&gt; &nbsp;<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
&gt; &nbsp;<a href="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/mailman/listinfo/python-dev</a><br>
&gt; &nbsp;Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/dalcinl%40gmail.com" target="_blank">http://mail.python.org/mailman/options/python-dev/dalcinl%40gmail.com</a><br>
<div><div></div><div class="Wj3C7c">&gt;<br>
<br>
<br>
--<br>
Lisandro Dalcín<br>
---------------<br>
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)<br>
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)<br>
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)<br>
PTLC - Güemes 3450, (3000) Santa Fe, Argentina<br>
Tel/Fax: +54-(0)342-451.1594<br>
</div></div></blockquote></div><br>