<br><div class="gmail_quote">On Fri, Nov 26, 2010 at 3:12 PM, Antonio Cuni <span dir="ltr">&lt;<a href="mailto:anto.cuni@gmail.com">anto.cuni@gmail.com</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 16/11/10 04:30, Dan Stromberg wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
BTW, it might cause confusion down the road to call something that is<br>
basically like cpython&#39;s bsddb (Berkeley DB) by the name &quot;dbm&quot; in pypy&#39;s<br>
library.  In the cpython standard library, &quot;dbm&quot; is an interface to ndbm<br>
databases.  These all provide the same dictionary-like interface to Python<br>
programs, but have somewhat different API&#39;s to C, and pretty different,<br>
incompatible on-disk representations.<br>
</blockquote>
<br></div>
Hi Dan,<br>
I played a bit (veeeery quickly) with dbm on both pypy and cpython, and I&#39;m not sure I get what you mean when you say that our dbm.py is equivalent to cpython&#39;s bsddb. E.g., I can create a db on cpython and open it from pypy, so it seems that the two modules are compatible.<br>

<br>
Moreover, I checked which libraries the links to. On CPython, it links to <a href="http://libdb-4.8.so" target="_blank">libdb-4.8.so</a>:<br>
<br>
viper2 ~ $ ldd /usr/lib/python2.6/lib-dynload/dbm.so<br>
        linux-gate.so.1 =&gt;  (0x00884000)<br>
        <a href="http://libdb-4.8.so" target="_blank">libdb-4.8.so</a> =&gt; /usr/lib/<a href="http://libdb-4.8.so" target="_blank">libdb-4.8.so</a> (0x00110000)<br>
        libpthread.so.0 =&gt; /lib/libpthread.so.0 (0x003de000)<br>
        libc.so.6 =&gt; /lib/libc.so.6 (0x003f8000)<br>
        /lib/ld-linux.so.2 (0x002e0000)<br>
<br>
the pypy version first tries to open libdb.so, then <a href="http://libdb-4.5.so" target="_blank">libdb-4.5.so</a>. I had to manually modify it to open version 4.8 (I agree that we should find a more general way to find it), but apart from that what I can see is that it uses the same underlying wrapper as CPython.<br>

<br>
So, to summarise: could you elaborate a bit more why we should delete dbm.py from pypy?<br>
<br>
ciao,<br>
Anto<br>
</blockquote></div><br><br>Looks like dbm at the API level: CPython dbm, pypy dbm<br>Looks like dbm on disk: CPython dbm<br>Looks like bsddb at the API level: CPython bsddb<br>Looks like bsddb on disk: CPython bsddb, pypy dbm<br>
<br>Don&#39;t let the common prefix fool you - libdb is Berkeley DB, while dbm is supposed to be ndbm.<br><br><a href="http://docs.python.org/library/dbm.html">http://docs.python.org/library/dbm.html</a><br><br>That is, pypy&#39;s dbm.py is perfectly self-consistent (other than a couple of likely memory leaks), but if you try to open a database from CPython using pypy&#39;s dbm module (or vice-versa), I don&#39;t believe it&#39;ll work.  EG:<br>
<br>$ /usr/local/cpython-2.7/bin/python<br>Python 2.7 (r27:82500, Aug  2 2010, 19:15:05)<br>[GCC 4.4.3] on linux2<br>Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br>
&gt;&gt;&gt; import dbm<br>&gt;&gt;&gt; d = dbm.open(&#39;d&#39;, &#39;n&#39;)<br>&gt;&gt;&gt; d[&#39;a&#39;] = &#39;b&#39;<br>&gt;&gt;&gt; d.close()<br>&gt;&gt;&gt;<br>benchbox-dstromberg:/tmp/dbm-test i686-pc-linux-gnu 30890 - above cmd done 2010 Fri Nov 26 04:14 PM<br>
<br>$ /usr/local/pypy-1.4/bin/pypy<br>Python 2.5.2 (79529, Nov 25 2010, 20:40:03)<br>[PyPy 1.4.0] on linux2<br>Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br>
And now for something completely different: ``casuality violations and flying&#39;&#39;<br>&gt;&gt;&gt;&gt; import dbm<br>&gt;&gt;&gt;&gt; d = dbm.open(&#39;d&#39;, &#39;r&#39;)<br>Traceback (most recent call last):<br>  File &quot;&lt;console&gt;&quot;, line 1, in &lt;module&gt;<br>
  File &quot;/usr/local/pypy-1.4/lib_pypy/dbm.py&quot;, line 172, in open<br>    raise error(&quot;Could not open file %s.db&quot; % filename)<br>error: Could not open file d.db<br>&gt;&gt;&gt;&gt;<br><br>HTH<br><br>