Author: Maciej Fijalkowski <[email protected]>
Branch: release-2.0-beta2
Changeset: r63057:a7ee6d151d4e
Date: 2013-04-05 14:21 +0200
http://bitbucket.org/pypy/pypy/changeset/a7ee6d151d4e/
Log: merge default
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -29,6 +29,7 @@
import string
import sys
import weakref
+import array
from threading import _get_ident as _thread_get_ident
try:
from __pypy__ import newlist_hint
@@ -218,7 +219,7 @@
const char **pzTail /* OUT: Pointer to unused portion of zSql */
);
-void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
+void sqlite3_result_blob(sqlite3_context*, const char*, int, void(*)(void*));
void sqlite3_result_double(sqlite3_context*, double);
void sqlite3_result_error(sqlite3_context*, const char*, int);
void sqlite3_result_error16(sqlite3_context*, const void*, int);
@@ -958,7 +959,11 @@
elif typ == _lib.SQLITE_BLOB:
blob =
_lib.sqlite3_column_blob(self.__statement._statement, i)
blob_len =
_lib.sqlite3_column_bytes(self.__statement._statement, i)
- val = _BLOB_TYPE(_ffi.buffer(blob, blob_len))
+ # make a copy of the data into an array, in order to get
+ # a read-write buffer in the end, and one that own the
+ # memory for a more predictable length of time than 'blob'
+ copy = array.array("c", _ffi.buffer(blob, blob_len))
+ val = _BLOB_TYPE(copy)
row.append(val)
return tuple(row)
diff --git a/pypy/doc/getting-started-python.rst
b/pypy/doc/getting-started-python.rst
--- a/pypy/doc/getting-started-python.rst
+++ b/pypy/doc/getting-started-python.rst
@@ -46,14 +46,14 @@
2. Install build-time dependencies. On a Debian box these are::
[user@debian-box ~]$ sudo apt-get install \
- gcc make python-dev libffi-dev pkg-config \
+ gcc make python-dev libffi-dev lib-sqlite3-dev pkg-config \
libz-dev libbz2-dev libncurses-dev libexpat1-dev \
libssl-dev libgc-dev python-sphinx python-greenlet
On a Fedora-16 box these are::
[user@fedora-or-rh-box ~]$ sudo yum install \
- gcc make python-devel libffi-devel pkgconfig \
+ gcc make python-devel libffi-devel lib-sqlite3-devel pkgconfig \
zlib-devel bzip2-devel ncurses-devel expat-devel \
openssl-devel gc-devel python-sphinx python-greenlet
@@ -62,6 +62,7 @@
* ``pkg-config`` (to help us locate libffi files)
* ``libz-dev`` (for the optional ``zlib`` module)
* ``libbz2-dev`` (for the optional ``bz2`` module)
+ * ``libsqlite3-dev`` (for the optional ``sqlite3`` module via cffi)
* ``libncurses-dev`` (for the optional ``_minimal_curses`` module)
* ``libexpat1-dev`` (for the optional ``pyexpat`` module)
* ``libssl-dev`` (for the optional ``_ssl`` module)
diff --git a/pypy/doc/index.rst b/pypy/doc/index.rst
--- a/pypy/doc/index.rst
+++ b/pypy/doc/index.rst
@@ -15,7 +15,7 @@
* `FAQ`_: some frequently asked questions.
-* `Release 2.0 beta 1`_: the latest official release
+* `Release 2.0 beta 2`_: the latest official release
* `PyPy Blog`_: news and status info about PyPy
@@ -75,7 +75,7 @@
.. _`Getting Started`: getting-started.html
.. _`Papers`: extradoc.html
.. _`Videos`: video-index.html
-.. _`Release 2.0 beta 1`: http://pypy.org/download.html
+.. _`Release 2.0 beta 2`: http://pypy.org/download.html
.. _`speed.pypy.org`: http://speed.pypy.org
.. _`RPython toolchain`: translation.html
.. _`potential project ideas`: project-ideas.html
diff --git a/pypy/doc/release-2.0.0-beta2.rst b/pypy/doc/release-2.0.0-beta2.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/release-2.0.0-beta2.rst
@@ -0,0 +1,84 @@
+===============
+PyPy 2.0 beta 2
+===============
+
+We're pleased to announce the 2.0 beta 2 release of PyPy. This is a major
+release of PyPy and we're getting very close to 2.0 final, however it includes
+quite a few new features that require further testing. Please test and report
+issues, so we can have a rock-solid 2.0 final. It also includes a performance
+regression of about 5% compared to 2.0 beta 1 that we hope to fix before
+2.0 final. The ARM support is not working yet and we're working hard to
+make it happen before the 2.0 final. The new major features are:
+
+* JIT now supports stackless features, that is greenlets and stacklets. This
+ means that JIT can now optimize the code that switches the context. It
enables
+ running `eventlet`_ and `gevent`_ on PyPy (although gevent requires some
+ special support that's not quite finished, read below).
+
+* This is the first PyPy release that includes `cffi`_ as a core library.
+ Version 0.6 comes included in the PyPy library. cffi has seen a lot of
+ adoption among library authors and we believe it's the best way to wrap
+ C libaries. You can see examples of cffi usage in `_curses.py`_ and
+ `_sqlite3.py`_ in the PyPy source code.
+
+You can download the PyPy 2.0 beta 2 release here:
+
+ http://pypy.org/download.html
+
+What is PyPy?
+=============
+
+PyPy is a very compliant Python interpreter, almost a drop-in replacement for
+CPython 2.7.3. It's fast (`pypy 2.0 beta 2 and cpython 2.7.3`_
+performance comparison) due to its integrated tracing JIT compiler.
+
+This release supports x86 machines running Linux 32/64, Mac OS X 64 or
+Windows 32. It also supports ARM machines running Linux, however this is
+disabled for the beta 2 release.
+Windows 64 work is still stalling, we would welcome a volunteer
+to handle that.
+
+.. _`pypy 2.0 beta 2 and cpython 2.7.3`: http://bit.ly/USXqpP
+
+How to use PyPy?
+================
+
+We suggest using PyPy from a `virtualenv`_. Once you have a virtualenv
+installed, you can follow instructions from `pypy documentation`_ on how
+to proceed. This document also covers other `installation schemes`_.
+
+.. _`pypy documentation`:
http://doc.pypy.org/en/latest/getting-started.html#installing-using-virtualenv
+.. _`virtualenv`: http://www.virtualenv.org/en/latest/
+.. _`installation schemes`:
http://doc.pypy.org/en/latest/getting-started.html#installing-pypy
+
+Highlights
+==========
+
+* ``cffi`` is officially supported by PyPy. It comes included in the standard
+ library, just use ``import cffi``
+
+* stackless support - `eventlet`_ just works and `gevent`_ requires `pypycore`_
+ and `pypy-hacks`_ branch of gevent (which mostly disables cython-based
+ modules)
+
+* callbacks from C are now much faster. pyexpat is about 3x faster, cffi
+ callbacks around the same
+
+* ``__length_hint__`` is implemented (PEP 424)
+
+* a lot of numpy improvements
+
+Improvements since 1.9
+======================
+
+* `JIT hooks`_ are now a powerful tool to introspect the JITting process that
+ PyPy performs
+
+* various performance improvements compared to 1.9 and 2.0 beta 1
+
+* operations on ``long`` objects are now as fast as in CPython (from
+ roughly 2x slower)
+
+* we now have special strategies for ``dict``/``set``/``list`` which contain
+ unicode strings, which means that now such collections will be both faster
+ and more compact.
diff --git a/pypy/doc/windows.rst b/pypy/doc/windows.rst
--- a/pypy/doc/windows.rst
+++ b/pypy/doc/windows.rst
@@ -111,6 +111,18 @@
cd bzip2-1.0.5
nmake -f makefile.msc
+The sqlite3 database library
+~~~~~~~~~~~~~~~~~~~~
+
+Download http://www.sqlite.org/2013/sqlite-amalgamation-3071601.zip and extract
+it into a directory under the base directory. Also get
+http://www.sqlite.org/2013/sqlite-dll-win32-x86-3071601.zip and extract the dll
+into the bin directory, and the sqlite3.def into the sources directory.
+Now build the import library so cffi can use the header and dll::
+ lib /DEF:sqlite3.def" /OUT:sqlite3.lib"
+ copy sqlite3.lib path\to\libs
+
+
The expat XML parser
~~~~~~~~~~~~~~~~~~~~
diff --git a/pypy/module/test_lib_pypy/test_sqlite3.py
b/pypy/module/test_lib_pypy/test_sqlite3.py
--- a/pypy/module/test_lib_pypy/test_sqlite3.py
+++ b/pypy/module/test_lib_pypy/test_sqlite3.py
@@ -198,3 +198,15 @@
con = _sqlite3.connect(':memory:')
con.row_factory = 42
con.execute('select 1')
+
+def test_returning_blob_must_own_memory():
+ import gc
+ con = _sqlite3.connect(":memory:")
+ con.create_function("returnblob", 0, lambda: buffer("blob"))
+ cur = con.cursor()
+ cur.execute("select returnblob()")
+ val = cur.fetchone()[0]
+ for i in range(5):
+ gc.collect()
+ got = (val[0], val[1], val[2], val[3])
+ assert got == ('b', 'l', 'o', 'b')
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -80,7 +80,7 @@
def __del__(self):
if self.addr_p:
- lltype.free(self.addr_p, flavor='raw')
+ lltype.free(self.addr_p, flavor='raw', track_allocation=False)
def setdata(self, addr, addrlen):
# initialize self.addr and self.addrlen. 'addr' can be a different
@@ -271,7 +271,8 @@
result = instantiate(INETAddress)
# store the malloc'ed data into 'result' as soon as possible
# to avoid leaks if an exception occurs inbetween
- sin = lltype.malloc(_c.sockaddr_in, flavor='raw', zero=True)
+ sin = lltype.malloc(_c.sockaddr_in, flavor='raw', zero=True,
+ track_allocation=False)
result.setdata(sin, sizeof(_c.sockaddr_in))
# PLAT sin_len
rffi.setintfield(sin, 'c_sin_family', AF_INET)
@@ -337,7 +338,8 @@
result = instantiate(INET6Address)
# store the malloc'ed data into 'result' as soon as possible
# to avoid leaks if an exception occurs inbetween
- sin = lltype.malloc(_c.sockaddr_in6, flavor='raw', zero=True)
+ sin = lltype.malloc(_c.sockaddr_in6, flavor='raw', zero=True,
+ track_allocation=False)
result.setdata(sin, sizeof(_c.sockaddr_in6))
rffi.setintfield(sin, 'c_sin6_family', AF_INET6)
rffi.structcopy(sin.c_sin6_addr, in6_addr)
@@ -360,7 +362,8 @@
maxlen = sizeof(struct)
def __init__(self, path):
- sun = lltype.malloc(_c.sockaddr_un, flavor='raw', zero=True)
+ sun = lltype.malloc(_c.sockaddr_un, flavor='raw', zero=True,
+ track_allocation=False)
baseofs = offsetof(_c.sockaddr_un, 'c_sun_path')
self.setdata(sun, baseofs + len(path))
rffi.setintfield(sun, 'c_sun_family', AF_UNIX)
@@ -409,7 +412,8 @@
maxlen = minlen = sizeof(struct)
def __init__(self, pid, groups):
- addr = lltype.malloc(_c.sockaddr_nl, flavor='raw', zero=True)
+ addr = lltype.malloc(_c.sockaddr_nl, flavor='raw', zero=True,
+ track_allocation=False)
self.setdata(addr, NETLINKAddress.maxlen)
rffi.setintfield(addr, 'c_nl_family', AF_NETLINK)
rffi.setintfield(addr, 'c_nl_pid', pid)
@@ -444,7 +448,8 @@
raise RSocketError("address family mismatched")
# copy into a new buffer the address that 'addrptr' points to
addrlen = rffi.cast(lltype.Signed, addrlen)
- buf = lltype.malloc(rffi.CCHARP.TO, addrlen, flavor='raw')
+ buf = lltype.malloc(rffi.CCHARP.TO, addrlen, flavor='raw',
+ track_allocation=False)
src = rffi.cast(rffi.CCHARP, addrptr)
for i in range(addrlen):
buf[i] = src[i]
@@ -456,7 +461,8 @@
result = instantiate(INETAddress)
elif result.family != AF_INET:
raise RSocketError("address family mismatched")
- sin = lltype.malloc(_c.sockaddr_in, flavor='raw', zero=True)
+ sin = lltype.malloc(_c.sockaddr_in, flavor='raw', zero=True,
+ track_allocation=False)
result.setdata(sin, sizeof(_c.sockaddr_in))
rffi.setintfield(sin, 'c_sin_family', AF_INET) # PLAT sin_len
rffi.setintfield(sin.c_sin_addr, 'c_s_addr', s_addr)
@@ -465,7 +471,8 @@
def make_null_address(family):
klass = familyclass(family)
result = instantiate(klass)
- buf = lltype.malloc(rffi.CCHARP.TO, klass.maxlen, flavor='raw', zero=True)
+ buf = lltype.malloc(rffi.CCHARP.TO, klass.maxlen, flavor='raw', zero=True,
+ track_allocation=False)
# Initialize the family to the correct value. Avoids surprizes on
# Windows when calling a function that unexpectedly does not set
# the output address (e.g. recvfrom() on a connected IPv4 socket).
diff --git a/rpython/rtyper/lltypesystem/rffi.py
b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -934,10 +934,8 @@
if tp is lltype.SingleFloat:
return 4
if tp is lltype.LongFloat:
- if globals()['r_void*'].BITS == 32:
- return 12
- else:
- return 16
+ import ctypes # :-/
+ return ctypes.sizeof(ctypes.c_longdouble)
assert isinstance(tp, lltype.Number)
if tp is lltype.Signed:
return LONG_BIT/8
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit