<br><div class="gmail_quote">On Fri, Nov 26, 2010 at 4:18 PM, Dan Stromberg <span dir="ltr"><<a href="mailto:drsalists@gmail.com">drsalists@gmail.com</a>></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><div></div><div class="h5"><br><div class="gmail_quote">On Fri, Nov 26, 2010 at 3:12 PM, Antonio Cuni <span dir="ltr"><<a href="mailto:anto.cuni@gmail.com" target="_blank">anto.cuni@gmail.com</a>></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>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's bsddb (Berkeley DB) by the name "dbm" in pypy's<br>
library. In the cpython standard library, "dbm" is an interface to ndbm<br>
databases. These all provide the same dictionary-like interface to Python<br>
programs, but have somewhat different API'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'm not sure I get what you mean when you say that our dbm.py is equivalent to cpython'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 => (0x00884000)<br>
<a href="http://libdb-4.8.so" target="_blank">libdb-4.8.so</a> => /usr/lib/<a href="http://libdb-4.8.so" target="_blank">libdb-4.8.so</a> (0x00110000)<br>
libpthread.so.0 => /lib/libpthread.so.0 (0x003de000)<br>
libc.so.6 => /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></div></div>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'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" target="_blank">http://docs.python.org/library/dbm.html</a><br>
<br>That is, pypy'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's dbm module (or vice-versa), I don't believe it'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 "help", "copyright", "credits" or "license" for more information.<br>
>>> import dbm<br>>>> d = dbm.open('d', 'n')<br>>>> d['a'] = 'b'<br>>>> d.close()<br>>>><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 "help", "copyright", "credits" or "license" for more information.<br>
And now for something completely different: ``casuality violations and flying''<br>>>>> import dbm<br>>>>> d = dbm.open('d', 'r')<br>Traceback (most recent call last):<br> File "<console>", line 1, in <module><br>
File "/usr/local/pypy-1.4/lib_pypy/dbm.py", line 172, in open<br> raise error("Could not open file %s.db" % filename)<br>error: Could not open file d.db<br>>>>><br><br>HTH<br><br>
</blockquote></div>Interesting. My CPython 2.7 build has:<br><br>$ ldd dbm.so<br> linux-gate.so.1 => (0x009ed000)<br> libgdbm.so.3 => /usr/lib/libgdbm.so.3 (0x00ed5000)<br> libgdbm_compat.so.3 => /usr/lib/libgdbm_compat.so.3 (0x00269000)<br>
libpthread.so.0 => /lib/libpthread.so.0 (0x00df3000)<br> libc.so.6 => /lib/libc.so.6 (0x00425000)<br> /lib/ld-linux.so.2 (0x00b7b000)<br>benchbox-dstromberg:/usr/local/cpython-2.7/lib/python2.7/lib-dynload i686-pc-linux-gnu 30430 - above cmd done 2010 Fri Nov 26 06:48 PM<br>
<br>...but <a href="http://docs.python.org/library/dbm.html">http://docs.python.org/library/dbm.html</a> plainly says it should be ndbm.<br><br>So which is wrong? The doc, or the module that's picking gdbm or Berkeley DB, as it sees fit?<br>
<br>