[pypy-commit] pypy fix-longevity: catchup with default
plan_rich
pypy.commits at gmail.com
Wed Mar 16 15:39:07 EDT 2016
Author: Richard Plangger <planrichi at gmail.com>
Branch: fix-longevity
Changeset: r83087:f64a2c834041
Date: 2016-03-15 11:52 +0100
http://bitbucket.org/pypy/pypy/changeset/f64a2c834041/
Log: catchup with default
diff too long, truncating to 2000 out of 17154 lines
diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -74,5 +74,6 @@
^rpython/doc/_build/.*$
^compiled
^.git/
+^.hypothesis/
^release/
^rpython/_cache$
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -18,3 +18,4 @@
f3ad1e1e1d6215e20d34bb65ab85ff9188c9f559 release-2.6.1
850edf14b2c75573720f59e95767335fb1affe55 release-4.0.0
5f8302b8bf9f53056e40426f10c72151564e5b19 release-4.0.1
+246c9cf22037b11dc0e8c29ce3f291d3b8c5935a release-5.0
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -240,6 +240,7 @@
Kristjan Valur Jonsson
David Lievens
Neil Blakey-Milner
+ Sergey Matyunin
Lutz Paelike
Lucio Torre
Lars Wassermann
@@ -271,6 +272,7 @@
Aaron Tubbs
Ben Darnell
Roberto De Ioris
+ Logan Chien
Juan Francisco Cantero Hurtado
Ruochen Huang
Jeong YunWon
diff --git a/lib-python/2.7/xml/etree/ElementTree.py b/lib-python/2.7/xml/etree/ElementTree.py
--- a/lib-python/2.7/xml/etree/ElementTree.py
+++ b/lib-python/2.7/xml/etree/ElementTree.py
@@ -1606,7 +1606,17 @@
pubid = pubid[1:-1]
if hasattr(self.target, "doctype"):
self.target.doctype(name, pubid, system[1:-1])
- elif self.doctype is not self._XMLParser__doctype:
+ elif 1: # XXX PyPy fix, used to be
+ # elif self.doctype is not self._XMLParser__doctype:
+ # but that condition is always True on CPython, as far
+ # as I can tell: self._XMLParser__doctype always
+ # returns a fresh unbound method object.
+ # On PyPy, unbound and bound methods have stronger
+ # unicity guarantees: self._XMLParser__doctype
+ # can return the same unbound method object, in
+ # some cases making the test above incorrectly False.
+ # (My guess would be that the line above is a backport
+ # from Python 3.)
# warn about deprecated call
self._XMLParser__doctype(name, pubid, system[1:-1])
self.doctype(name, pubid, system[1:-1])
diff --git a/lib_pypy/ctypes_config_cache/rebuild.py b/lib_pypy/ctypes_config_cache/rebuild.py
--- a/lib_pypy/ctypes_config_cache/rebuild.py
+++ b/lib_pypy/ctypes_config_cache/rebuild.py
@@ -9,9 +9,8 @@
_dirpath = os.path.dirname(__file__) or os.curdir
-from rpython.tool.ansi_print import ansi_log
-log = py.log.Producer("ctypes_config_cache")
-py.log.setconsumer("ctypes_config_cache", ansi_log)
+from rpython.tool.ansi_print import AnsiLogger
+log = AnsiLogger("ctypes_config_cache")
def rebuild_one(name):
diff --git a/pypy/doc/conf.py b/pypy/doc/conf.py
--- a/pypy/doc/conf.py
+++ b/pypy/doc/conf.py
@@ -123,7 +123,7 @@
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
-#html_title = None
+html_title = 'PyPy documentation'
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
diff --git a/pypy/doc/contributor.rst b/pypy/doc/contributor.rst
--- a/pypy/doc/contributor.rst
+++ b/pypy/doc/contributor.rst
@@ -11,29 +11,29 @@
Amaury Forgeot d'Arc
Antonio Cuni
Samuele Pedroni
+ Matti Picus
Alex Gaynor
Brian Kearns
- Matti Picus
Philip Jenvey
Michael Hudson
+ Ronan Lamy
David Schneider
+ Manuel Jacob
Holger Krekel
Christian Tismer
Hakan Ardo
- Manuel Jacob
- Ronan Lamy
Benjamin Peterson
+ Richard Plangger
Anders Chrigstrom
Eric van Riet Paap
Wim Lavrijsen
- Richard Plangger
Richard Emslie
Alexander Schremmer
Dan Villiom Podlaski Christiansen
+ Remi Meier
Lukas Diekmann
Sven Hager
Anders Lehmann
- Remi Meier
Aurelien Campeas
Niklaus Haldimann
Camillo Bruni
@@ -42,8 +42,8 @@
Romain Guillebert
Leonardo Santagada
Seo Sanghyeon
+ Ronny Pfannschmidt
Justin Peel
- Ronny Pfannschmidt
David Edelsohn
Anders Hammarquist
Jakub Gustak
@@ -65,6 +65,7 @@
Tyler Wade
Michael Foord
Stephan Diehl
+ Vincent Legoll
Stefan Schwarzer
Valentino Volonghi
Tomek Meka
@@ -75,9 +76,9 @@
Jean-Paul Calderone
Timo Paulssen
Squeaky
+ Marius Gedminas
Alexandre Fayolle
Simon Burton
- Marius Gedminas
Martin Matusiak
Konstantin Lopuhin
Wenzhu Man
@@ -86,16 +87,20 @@
Ivan Sichmann Freitas
Greg Price
Dario Bertini
+ Stefano Rivera
Mark Pearse
Simon Cross
Andreas Stührk
- Stefano Rivera
+ Edd Barrett
Jean-Philippe St. Pierre
Guido van Rossum
Pavel Vinogradov
+ Jeremy Thurgood
Paweł Piotr Przeradowski
+ Spenser Bauman
Paul deGrandis
Ilya Osadchiy
+ marky1991
Tobias Oberstein
Adrian Kuhn
Boris Feigin
@@ -104,14 +109,12 @@
Georg Brandl
Bert Freudenberg
Stian Andreassen
- Edd Barrett
+ Tobias Pape
Wanja Saatkamp
Gerald Klix
Mike Blume
- Tobias Pape
Oscar Nierstrasz
Stefan H. Muller
- Jeremy Thurgood
Rami Chowdhury
Eugene Oden
Henry Mason
@@ -123,6 +126,8 @@
Lukas Renggli
Guenter Jantzen
Ned Batchelder
+ Tim Felgentreff
+ Anton Gulenko
Amit Regmi
Ben Young
Nicolas Chauvat
@@ -132,12 +137,12 @@
Nicholas Riley
Jason Chu
Igor Trindade Oliveira
- Tim Felgentreff
+ Yichao Yu
Rocco Moretti
Gintautas Miliauskas
Michael Twomey
Lucian Branescu Mihaila
- Yichao Yu
+ Devin Jeanpierre
Gabriel Lavoie
Olivier Dormond
Jared Grubb
@@ -161,33 +166,33 @@
Stanislaw Halik
Mikael Schönenberg
Berkin Ilbeyi
- Elmo M?ntynen
+ Elmo Mäntynen
+ Faye Zhao
Jonathan David Riehl
Anders Qvist
Corbin Simpson
Chirag Jadwani
Beatrice During
Alex Perry
- Vincent Legoll
+ Vaibhav Sood
Alan McIntyre
- Spenser Bauman
+ William Leslie
Alexander Sedov
Attila Gobi
+ Jasper.Schulz
Christopher Pope
- Devin Jeanpierre
- Vaibhav Sood
Christian Tismer
Marc Abramowitz
Dan Stromberg
Arjun Naik
Valentina Mukhamedzhanova
Stefano Parmesan
+ Mark Young
Alexis Daboville
Jens-Uwe Mager
Carl Meyer
Karl Ramm
Pieter Zieschang
- Anton Gulenko
Gabriel
Lukas Vacek
Andrew Dalke
@@ -195,6 +200,7 @@
Jakub Stasiak
Nathan Taylor
Vladimir Kryachko
+ Omer Katz
Jacek Generowicz
Alejandro J. Cura
Jacob Oscarson
@@ -204,11 +210,13 @@
Kristjan Valur Jonsson
David Lievens
Neil Blakey-Milner
+ Sergey Matyunin
Lutz Paelike
Lucio Torre
Lars Wassermann
Philipp Rustemeuer
Henrik Vendelbo
+ Richard Lancaster
Dan Buch
Miguel de Val Borro
Artur Lisiecki
@@ -220,20 +228,21 @@
Tomo Cocoa
Kim Jin Su
Toni Mattis
+ Amber Brown
Lucas Stadler
Julian Berman
Markus Holtermann
roberto at goyle
Yury V. Zaytsev
Anna Katrina Dominguez
- William Leslie
Bobby Impollonia
- Faye Zhao
timo at eistee.fritz.box
Andrew Thompson
Yusei Tahara
+ Aaron Tubbs
Ben Darnell
Roberto De Ioris
+ Logan Chien
Juan Francisco Cantero Hurtado
Ruochen Huang
Jeong YunWon
@@ -243,6 +252,7 @@
Christopher Armstrong
Michael Hudson-Doyle
Anders Sigfridsson
+ Nikolay Zinov
Yasir Suhail
Jason Michalski
rafalgalczynski at gmail.com
@@ -252,6 +262,7 @@
Gustavo Niemeyer
Stephan Busemann
Rafał Gałczyński
+ Matt Bogosian
Christian Muirhead
Berker Peksag
James Lan
@@ -286,9 +297,9 @@
Stefan Marr
jiaaro
Mads Kiilerich
- Richard Lancaster
opassembler.py
Antony Lee
+ Jason Madden
Yaroslav Fedevych
Jim Hunziker
Markus Unterwaditzer
@@ -297,6 +308,7 @@
squeaky
Zearin
soareschen
+ Jonas Pfannschmidt
Kurt Griffiths
Mike Bayer
Matthew Miller
@@ -311,4 +323,3 @@
Julien Phalip
Roman Podoliaka
Dan Loewenherz
-
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -265,7 +265,7 @@
return False
def evil(y):
- d = {x(): 1}
+ d = {X(): 1}
X.__eq__ = __evil_eq__
d[y] # might trigger a call to __eq__?
diff --git a/pypy/doc/how-to-release.rst b/pypy/doc/how-to-release.rst
--- a/pypy/doc/how-to-release.rst
+++ b/pypy/doc/how-to-release.rst
@@ -76,5 +76,4 @@
* add a tag on the pypy/jitviewer repo that corresponds to pypy release
* add a tag on the codespeed web site that corresponds to pypy release
-* update the version number in {rpython,pypy}/doc/conf.py.
* revise versioning at https://readthedocs.org/projects/pypy
diff --git a/pypy/doc/index-of-release-notes.rst b/pypy/doc/index-of-release-notes.rst
--- a/pypy/doc/index-of-release-notes.rst
+++ b/pypy/doc/index-of-release-notes.rst
@@ -6,6 +6,7 @@
.. toctree::
+ release-5.0.0.rst
release-4.0.1.rst
release-4.0.0.rst
release-2.6.1.rst
diff --git a/pypy/doc/index-of-whatsnew.rst b/pypy/doc/index-of-whatsnew.rst
--- a/pypy/doc/index-of-whatsnew.rst
+++ b/pypy/doc/index-of-whatsnew.rst
@@ -7,6 +7,7 @@
.. toctree::
whatsnew-head.rst
+ whatsnew-5.0.0.rst
whatsnew-4.0.1.rst
whatsnew-4.0.0.rst
whatsnew-2.6.1.rst
diff --git a/pypy/doc/project-ideas.rst b/pypy/doc/project-ideas.rst
--- a/pypy/doc/project-ideas.rst
+++ b/pypy/doc/project-ideas.rst
@@ -167,22 +167,13 @@
* `hg`
-Embedding PyPy and improving CFFI
----------------------------------
-
-PyPy has some basic :doc:`embedding infrastructure <embedding>`. The idea would be to improve
-upon that with cffi hacks that can automatically generate embeddable .so/.dll
-library
-
-
Optimising cpyext (CPython C-API compatibility layer)
-----------------------------------------------------
A lot of work has gone into PyPy's implementation of CPython's C-API over
the last years to let it reach a practical level of compatibility, so that
C extensions for CPython work on PyPy without major rewrites. However,
-there are still many edges and corner cases where it misbehaves, and it has
-not received any substantial optimisation so far.
+there are still many edges and corner cases where it misbehaves.
The objective of this project is to fix bugs in cpyext and to optimise
several performance critical parts of it, such as the reference counting
diff --git a/pypy/doc/release-5.0.0.rst b/pypy/doc/release-5.0.0.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/release-5.0.0.rst
@@ -0,0 +1,230 @@
+========
+PyPy 5.0
+========
+
+We have released PyPy 5.0, about three months after PyPy 4.0.1.
+We encourage all users of PyPy to update to this version. Apart from the usual
+bug fixes, there is an ongoing effort to improve the warmup time and memory
+usage of JIT-related metadata. The exact effects depend vastly on the program
+you're running and can range from insignificant to warmup being up to 30%
+faster and memory dropping by about 30%.
+
+We also merged a major upgrade to our C-API layer (cpyext), simplifying the
+interaction between c-level objects and PyPy interpreter level objects. As a
+result, lxml (prerelease) with its cython compiled component
+`passes all tests`_ on PyPy. The new cpyext is also much faster.
+
+vmprof_ has been a go-to profiler for PyPy on linux for a few releases
+and we're happy to announce that thanks to the cooperation with jetbrains,
+vmprof now works on Linux, OS X and Windows on both PyPy and CPython.
+
+You can download the PyPy 5.0 release here:
+
+ http://pypy.org/download.html
+
+We would like to thank our donors for the continued support of the PyPy
+project.
+
+We would also like to thank our contributors and
+encourage new people to join the project. PyPy has many
+layers and we need help with all of them: `PyPy`_ and `RPython`_ documentation
+improvements, tweaking popular `modules`_ to run on pypy, or general `help`_
+with making RPython's JIT even better.
+
+CFFI
+====
+
+While not applicable only to PyPy, `cffi`_ is arguably our most significant
+contribution to the python ecosystem. PyPy 5.0 ships with
+`cffi-1.5.2`_ which now allows embedding PyPy (or cpython) in a C program.
+
+.. _`PyPy`: http://doc.pypy.org
+.. _`RPython`: https://rpython.readthedocs.org
+.. _`cffi`: https://cffi.readthedocs.org
+.. _`cffi-1.5.2`: http://cffi.readthedocs.org/en/latest/whatsnew.html#v1-5-2
+.. _`modules`: http://doc.pypy.org/en/latest/project-ideas.html#make-more-python-modules-pypy-friendly
+.. _`help`: http://doc.pypy.org/en/latest/project-ideas.html
+.. _`numpy`: https://bitbucket.org/pypy/numpy
+.. _`passes all tests`: https://bitbucket.org/pypy/compatibility/wiki/lxml
+.. _vmprof: http://vmprof.readthedocs.org
+
+What is PyPy?
+=============
+
+PyPy is a very compliant Python interpreter, almost a drop-in replacement for
+CPython 2.7. It's fast (`PyPy and CPython 2.7.x`_ performance comparison)
+due to its integrated tracing JIT compiler.
+
+We also welcome developers of other
+`dynamic languages`_ to see what RPython can do for them.
+
+This release supports **x86** machines on most common operating systems
+(Linux 32/64, Mac OS X 64, Windows 32, OpenBSD, FreeBSD),
+newer **ARM** hardware (ARMv6 or ARMv7, with VFPv3) running Linux, and the
+big- and little-endian variants of **PPC64** running Linux.
+
+.. _`PyPy and CPython 2.7.x`: http://speed.pypy.org
+.. _`dynamic languages`: http://pypyjs.org
+
+Other Highlights (since 4.0.1 released in November 2015)
+=========================================================
+
+* New features:
+
+ * Support embedding PyPy in a C-program via cffi and static callbacks in cffi.
+ This deprecates the old method of embedding PyPy
+
+ * Refactor vmprof to work cross-operating-system, deprecate using buggy
+ libunwind on Linux platforms. Vmprof even works on Windows now.
+
+ * Support more of the C-API type slots, like tp_getattro, and fix C-API
+ macros, functions, and structs such as _PyLong_FromByteArray(),
+ PyString_GET_SIZE, f_locals in PyFrameObject, Py_NAN, co_filename in
+ PyCodeObject
+
+ * Use a more stable approach for allocating PyObjects in cpyext. (see
+ `blog post`_). Once the PyObject corresponding to a PyPy object is created,
+ it stays around at the same location until the death of the PyPy object.
+ Done with a little bit of custom GC support. It allows us to kill the
+ notion of "borrowing" inside cpyext, reduces 4 dictionaries down to 1, and
+ significantly simplifies the whole approach (which is why it is a new
+ feature while technically a refactoring) and allows PyPy to support the
+ populart lxml module (as of the *next* release) with no PyPy specific
+ patches needed
+
+ * Make the default filesystem encoding ASCII, like CPython
+
+ * Use `hypothesis`_ in test creation, which is great for randomizing tests
+
+* Bug Fixes
+
+ * Backport always using os.urandom for uuid4 from cpython and fix the JIT as well
+ (issue #2202)
+
+ * More completely support datetime, optimize timedelta creation
+
+ * Fix for issue #2185 which caused an inconsistent list of operations to be
+ generated by the unroller, appeared in a complicated DJango app
+
+ * Fix an elusive issue with stacklets on shadowstack which showed up when
+ forgetting stacklets without resuming them
+
+ * Fix entrypoint() which now acquires the GIL
+
+ * Fix direct_ffi_call() so failure does not bail out before setting CALL_MAY_FORCE
+
+ * Fix (de)pickling long values by simplifying the implementation
+
+ * Fix RPython rthread so that objects stored as threadlocal do not force minor
+ GC collection and are kept alive automatically. This improves perfomance of
+ short-running Python callbacks and prevents resetting such object between
+ calls
+
+ * Support floats as parameters to itertools.isslice()
+
+ * Check for the existence of CODESET, ignoring it should have prevented PyPy
+ from working on FreeBSD
+
+ * Fix for corner case (likely shown by Krakatau) for consecutive guards with
+ interdependencies
+
+ * Fix applevel bare class method comparisons which should fix pretty printing
+ in IPython
+
+ * Issues reported with our previous release were resolved_ after reports from users on
+ our issue tracker at https://bitbucket.org/pypy/pypy/issues or on IRC at
+ #pypy
+
+* Numpy:
+
+ * Updates to numpy 1.10.2 (incompatibilities and not-implemented features
+ still exist)
+
+ * Support dtype=(('O', spec)) union while disallowing record arrays with
+ mixed object, non-object values
+
+ * Remove all traces of micronumpy from cpyext if --withoutmod-micronumpy option used
+
+ * Support indexing filtering with a boolean ndarray
+
+ * Support partition() as an app-level function, together with a cffi wrapper
+ in pypy/numpy, this now provides partial support for partition()
+
+* Performance improvements:
+
+ * Optimize global lookups
+
+ * Improve the memory signature of numbering instances in the JIT. This should
+ massively decrease the amount of memory consumed by the JIT, which is
+ significant for most programs. Also compress the numberings using variable-
+ size encoding
+
+ * Optimize string concatenation
+
+ * Use INT_LSHIFT instead of INT_MUL when possible
+
+ * Improve struct.unpack by casting directly from the underlying buffer.
+ Unpacking floats and doubles is about 15 times faster, and integer types
+ about 50% faster (on 64 bit integers). This was then subsequently
+ improved further in optimizeopt.py.
+
+ * Optimize two-tuple lookups in mapdict, which improves warmup of instance
+ variable access somewhat
+
+ * Reduce all guards from int_floordiv_ovf if one of the arguments is constant
+
+ * Identify permutations of attributes at instance creation, reducing the
+ number of bridges created
+
+ * Greatly improve re.sub() performance
+
+
+* Internal refactorings:
+
+ * Refactor and improve exception analysis in the annotator
+
+ * Remove unnecessary special handling of space.wrap().
+
+ * Support list-resizing setslice operations in RPython
+
+ * Tweak the trace-too-long heuristic for multiple jit drivers
+
+ * Refactor bookkeeping (such a cool word - three double letters) in the
+ annotater
+
+ * Refactor wrappers for OS functions from rtyper to rlib and simplify them
+
+ * Simplify backend loading instructions to only use four variants
+
+ * Simplify GIL handling in non-jitted code
+
+ * Refactor naming in optimizeopt
+
+ * Change GraphAnalyzer to use a more precise way to recognize external
+ functions and fix null pointer handling, generally clean up external
+ function handling
+
+ * Remove pure variants of ``getfield_gc_*`` operations from the JIT by
+ determining purity while tracing
+
+ * Refactor databasing
+
+ * Simplify bootstrapping in cpyext
+
+ * Refactor rtyper debug code into python.rtyper.debug
+
+ * Seperate structmember.h from Python.h Also enhance creating api functions
+ to specify which header file they appear in (previously only pypy_decl.h)
+
+ * Fix tokenizer to enforce universal newlines, needed for Python 3 support
+
+.. _resolved: http://doc.pypy.org/en/latest/whatsnew-5.0.0.html
+.. _`hypothesis`: http://hypothesis.readthedocs.org
+.. _`blog post`: http://morepypy.blogspot.com/2016/02/c-api-support-update.html
+
+Please update, and continue to help us make PyPy better.
+
+Cheers
+
+The PyPy Team
+
diff --git a/pypy/doc/whatsnew-5.0.0.rst b/pypy/doc/whatsnew-5.0.0.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/whatsnew-5.0.0.rst
@@ -0,0 +1,197 @@
+======================
+What's new in PyPy 5.0
+======================
+
+.. this is a revision shortly after release-4.0.1
+.. startrev: 4b5c840d0da2
+
+Fixed ``_PyLong_FromByteArray()``, which was buggy.
+
+Fixed a crash with stacklets (or greenlets) on non-Linux machines
+which showed up if you forget stacklets without resuming them.
+
+.. branch: numpy-1.10
+
+Fix tests to run cleanly with -A and start to fix micronumpy for upstream numpy
+which is now 1.10.2
+
+.. branch: osx-flat-namespace
+
+Fix the cpyext tests on OSX by linking with -flat_namespace
+
+.. branch: anntype
+
+Refactor and improve exception analysis in the annotator.
+
+.. branch: posita/2193-datetime-timedelta-integrals
+
+Fix issue #2193. ``isinstance(..., int)`` => ``isinstance(..., numbers.Integral)``
+to allow for alternate ``int``-like implementations (e.g., ``future.types.newint``)
+
+.. branch: faster-rstruct
+
+Improve the performace of struct.unpack, which now directly reads inside the
+string buffer and directly casts the bytes to the appropriate type, when
+allowed. Unpacking of floats and doubles is about 15 times faster now, while
+for integer types it's up to ~50% faster for 64bit integers.
+
+.. branch: wrap-specialisation
+
+Remove unnecessary special handling of space.wrap().
+
+.. branch: compress-numbering
+
+Improve the memory signature of numbering instances in the JIT. This should massively
+decrease the amount of memory consumed by the JIT, which is significant for most programs.
+
+.. branch: fix-trace-too-long-heuristic
+
+Improve the heuristic when disable trace-too-long
+
+.. branch: fix-setslice-can-resize
+
+Make rlist's ll_listsetslice() able to resize the target list to help
+simplify objspace/std/listobject.py. Was issue #2196.
+
+.. branch: anntype2
+
+A somewhat random bunch of changes and fixes following up on branch 'anntype'. Highlights:
+
+- Implement @doubledispatch decorator and use it for intersection() and difference().
+
+- Turn isinstance into a SpaceOperation
+
+- Create a few direct tests of the fundamental annotation invariant in test_model.py
+
+- Remove bookkeeper attribute from DictDef and ListDef.
+
+.. branch: cffi-static-callback
+
+.. branch: vecopt-absvalue
+
+- Enhancement. Removed vector fields from AbstractValue.
+
+.. branch: memop-simplify2
+
+Simplification. Backends implement too many loading instructions, only having a slightly different interface.
+Four new operations (gc_load/gc_load_indexed, gc_store/gc_store_indexed) replace all the
+commonly known loading operations
+
+.. branch: more-rposix
+
+Move wrappers for OS functions from `rpython/rtyper` to `rpython/rlib` and
+turn them into regular RPython functions. Most RPython-compatible `os.*`
+functions are now directly accessible as `rpython.rposix.*`.
+
+.. branch: always-enable-gil
+
+Simplify a bit the GIL handling in non-jitted code. Fixes issue #2205.
+
+.. branch: flowspace-cleanups
+
+Trivial cleanups in flowspace.operation : fix comment & duplicated method
+
+.. branch: test-AF_NETLINK
+
+Add a test for pre-existing AF_NETLINK support. Was part of issue #1942.
+
+.. branch: small-cleanups-misc
+
+Trivial misc cleanups: typo, whitespace, obsolete comments
+
+.. branch: cpyext-slotdefs
+.. branch: fix-missing-canraise
+.. branch: whatsnew
+
+.. branch: fix-2211
+
+Fix the cryptic exception message when attempting to use extended slicing
+in rpython. Was issue #2211.
+
+.. branch: ec-keepalive
+
+Optimize the case where, in a new C-created thread, we keep invoking
+short-running Python callbacks. (CFFI on CPython has a hack to achieve
+the same result.) This can also be seen as a bug fix: previously,
+thread-local objects would be reset between two such calls.
+
+.. branch: globals-quasiimmut
+
+Optimize global lookups.
+
+.. branch: cffi-static-callback-embedding
+
+Updated to CFFI 1.5, which supports a new way to do embedding.
+Deprecates http://pypy.readthedocs.org/en/latest/embedding.html.
+
+.. branch: fix-cpython-ssl-tests-2.7
+
+Fix SSL tests by importing cpython's patch
+
+
+.. branch: remove-getfield-pure
+
+Remove pure variants of ``getfield_gc_*`` operations from the JIT. Relevant
+optimizations instead consult the field descriptor to determine the purity of
+the operation. Additionally, pure ``getfield`` operations are now handled
+entirely by `rpython/jit/metainterp/optimizeopt/heap.py` rather than
+`rpython/jit/metainterp/optimizeopt/pure.py`, which can result in better codegen
+for traces containing a large number of pure getfield operations.
+
+.. branch: exctrans
+
+Try to ensure that no new functions get annotated during the 'source_c' phase.
+Refactor sandboxing to operate at a higher level.
+
+.. branch: cpyext-bootstrap
+
+.. branch: vmprof-newstack
+
+Refactor vmprof to work cross-operating-system.
+
+.. branch: seperate-strucmember_h
+
+Seperate structmember.h from Python.h Also enhance creating api functions
+to specify which header file they appear in (previously only pypy_decl.h)
+
+.. branch: llimpl
+
+Refactor register_external(), remove running_on_llinterp mechanism and
+apply sandbox transform on externals at the end of annotation.
+
+.. branch: cffi-embedding-win32
+
+.. branch: windows-vmprof-support
+
+vmprof should work on Windows.
+
+
+.. branch: reorder-map-attributes
+
+When creating instances and adding attributes in several different orders
+depending on some condition, the JIT would create too much code. This is now
+fixed.
+
+.. branch: cpyext-gc-support-2
+
+Improve CPython C API support, which means lxml now runs unmodified
+(after removing pypy hacks, pending pull request)
+
+.. branch: look-inside-tuple-hash
+
+Look inside tuple hash, improving mdp benchmark
+
+.. branch: vlen-resume
+
+Compress resume data, saving 10-20% of memory consumed by the JIT
+
+.. branch: issue-2248
+
+.. branch: ndarray-setitem-filtered
+
+Fix boolean-array indexing in micronumpy
+
+.. branch: numpy_partition
+Support ndarray.partition() as an app-level function numpy.core._partition_use,
+provided as a cffi wrapper to upstream's implementation in the pypy/numpy repo
+
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -1,173 +1,25 @@
=========================
-What's new in PyPy 4.1.+
+What's new in PyPy 5.0.+
=========================
-.. this is a revision shortly after release-4.0.1
-.. startrev: 4b5c840d0da2
+.. this is a revision shortly after release-5.0
+.. startrev: b238b48f9138
-Fixed ``_PyLong_FromByteArray()``, which was buggy.
+.. branch: s390x-backend
-Fixed a crash with stacklets (or greenlets) on non-Linux machines
-which showed up if you forget stacklets without resuming them.
+The jit compiler backend implementation for the s390x architecutre.
+The backend manages 64-bit values in the literal pool of the assembly instead of loading them as immediates.
+It includes a simplification for the operation 'zero_array'. Start and length parameters are bytes instead of size.
-.. branch: numpy-1.10
+.. branch: remove-py-log
-Fix tests to run cleanly with -A and start to fix micronumpy for upstream numpy
-which is now 1.10.2
+Replace py.log with something simpler, which should speed up logging
-.. branch: osx-flat-namespace
+.. branch: where_1_arg
-Fix the cpyext tests on OSX by linking with -flat_namespace
+Implemented numpy.where for 1 argument (thanks sergem)
-.. branch: anntype
+.. branch: fix_indexing_by_numpy_int
-Refactor and improve exception analysis in the annotator.
-
-.. branch: posita/2193-datetime-timedelta-integrals
-
-Fix issue #2193. ``isinstance(..., int)`` => ``isinstance(..., numbers.Integral)``
-to allow for alternate ``int``-like implementations (e.g., ``future.types.newint``)
-
-.. branch: faster-rstruct
-
-Improve the performace of struct.unpack, which now directly reads inside the
-string buffer and directly casts the bytes to the appropriate type, when
-allowed. Unpacking of floats and doubles is about 15 times faster now, while
-for integer types it's up to ~50% faster for 64bit integers.
-
-.. branch: wrap-specialisation
-
-Remove unnecessary special handling of space.wrap().
-
-.. branch: compress-numbering
-
-Improve the memory signature of numbering instances in the JIT. This should massively
-decrease the amount of memory consumed by the JIT, which is significant for most programs.
-
-.. branch: fix-trace-too-long-heuristic
-
-Improve the heuristic when disable trace-too-long
-
-.. branch: fix-setslice-can-resize
-
-Make rlist's ll_listsetslice() able to resize the target list to help
-simplify objspace/std/listobject.py. Was issue #2196.
-
-.. branch: anntype2
-
-A somewhat random bunch of changes and fixes following up on branch 'anntype'. Highlights:
-
-- Implement @doubledispatch decorator and use it for intersection() and difference().
-
-- Turn isinstance into a SpaceOperation
-
-- Create a few direct tests of the fundamental annotation invariant in test_model.py
-
-- Remove bookkeeper attribute from DictDef and ListDef.
-
-.. branch: cffi-static-callback
-
-.. branch: vecopt-absvalue
-
-- Enhancement. Removed vector fields from AbstractValue.
-
-.. branch: memop-simplify2
-
-Simplification. Backends implement too many loading instructions, only having a slightly different interface.
-Four new operations (gc_load/gc_load_indexed, gc_store/gc_store_indexed) replace all the
-commonly known loading operations
-
-.. branch: more-rposix
-
-Move wrappers for OS functions from `rpython/rtyper` to `rpython/rlib` and
-turn them into regular RPython functions. Most RPython-compatible `os.*`
-functions are now directly accessible as `rpython.rposix.*`.
-
-.. branch: always-enable-gil
-
-Simplify a bit the GIL handling in non-jitted code. Fixes issue #2205.
-
-.. branch: flowspace-cleanups
-
-Trivial cleanups in flowspace.operation : fix comment & duplicated method
-
-.. branch: test-AF_NETLINK
-
-Add a test for pre-existing AF_NETLINK support. Was part of issue #1942.
-
-.. branch: small-cleanups-misc
-
-Trivial misc cleanups: typo, whitespace, obsolete comments
-
-.. branch: cpyext-slotdefs
-.. branch: fix-missing-canraise
-.. branch: whatsnew
-
-.. branch: fix-2211
-
-Fix the cryptic exception message when attempting to use extended slicing
-in rpython. Was issue #2211.
-
-.. branch: ec-keepalive
-
-Optimize the case where, in a new C-created thread, we keep invoking
-short-running Python callbacks. (CFFI on CPython has a hack to achieve
-the same result.) This can also be seen as a bug fix: previously,
-thread-local objects would be reset between two such calls.
-
-.. branch: globals-quasiimmut
-
-Optimize global lookups.
-
-.. branch: cffi-static-callback-embedding
-
-Updated to CFFI 1.5, which supports a new way to do embedding.
-Deprecates http://pypy.readthedocs.org/en/latest/embedding.html.
-
-.. branch: fix-cpython-ssl-tests-2.7
-
-Fix SSL tests by importing cpython's patch
-
-
-.. branch: remove-getfield-pure
-
-Remove pure variants of ``getfield_gc_*`` operations from the JIT. Relevant
-optimizations instead consult the field descriptor to determine the purity of
-the operation. Additionally, pure ``getfield`` operations are now handled
-entirely by `rpython/jit/metainterp/optimizeopt/heap.py` rather than
-`rpython/jit/metainterp/optimizeopt/pure.py`, which can result in better codegen
-for traces containing a large number of pure getfield operations.
-
-.. branch: exctrans
-
-Try to ensure that no new functions get annotated during the 'source_c' phase.
-Refactor sandboxing to operate at a higher level.
-
-.. branch: cpyext-bootstrap
-
-.. branch: vmprof-newstack
-
-Refactor vmprof to work cross-operating-system.
-
-.. branch: seperate-strucmember_h
-
-Seperate structmember.h from Python.h Also enhance creating api functions
-to specify which header file they appear in (previously only pypy_decl.h)
-
-.. branch: llimpl
-
-Refactor register_external(), remove running_on_llinterp mechanism and
-apply sandbox transform on externals at the end of annotation.
-
-.. branch: cffi-embedding-win32
-
-.. branch: windows-vmprof-support
-
-vmprof should work on Windows.
-
-
-.. branch: reorder-map-attributes
-
-When creating instances and adding attributes in several different orders
-depending on some condition, the JIT would create too much code. This is now
-fixed.
\ No newline at end of file
+Implement yet another strange numpy indexing compatibility; indexing by a scalar
+returns a scalar
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -13,6 +13,9 @@
from pypy.interpreter.argument import Arguments
from rpython.rlib import jit
+from rpython.rlib.rarithmetic import LONG_BIT
+from rpython.rlib.rbigint import rbigint
+
funccallunrolling = unrolling_iterable(range(4))
@@ -557,6 +560,26 @@
return space.w_False
return space.eq(self.w_function, w_other.w_function)
+ def is_w(self, space, other):
+ if not isinstance(other, Method):
+ return False
+ return (self.w_instance is other.w_instance and
+ self.w_function is other.w_function and
+ self.w_class is other.w_class)
+
+ def immutable_unique_id(self, space):
+ from pypy.objspace.std.util import IDTAG_METHOD as tag
+ from pypy.objspace.std.util import IDTAG_SHIFT
+ if self.w_instance is not None:
+ id = space.bigint_w(space.id(self.w_instance))
+ id = id.lshift(LONG_BIT)
+ else:
+ id = rbigint.fromint(0)
+ id = id.or_(space.bigint_w(space.id(self.w_function)))
+ id = id.lshift(LONG_BIT).or_(space.bigint_w(space.id(self.w_class)))
+ id = id.lshift(IDTAG_SHIFT).int_or_(tag)
+ return space.newlong_from_rbigint(id)
+
def descr_method_hash(self):
space = self.space
w_result = space.hash(self.w_function)
diff --git a/pypy/interpreter/mixedmodule.py b/pypy/interpreter/mixedmodule.py
--- a/pypy/interpreter/mixedmodule.py
+++ b/pypy/interpreter/mixedmodule.py
@@ -3,7 +3,7 @@
from pypy.interpreter import gateway
from pypy.interpreter.error import OperationError
from pypy.interpreter.baseobjspace import W_Root
-import os, sys
+import sys
class MixedModule(Module):
applevel_name = None
@@ -60,7 +60,7 @@
def save_module_content_for_future_reload(self):
self.w_initialdict = self.space.call_method(self.w_dict, 'items')
-
+ @classmethod
def get_applevel_name(cls):
""" NOT_RPYTHON """
if cls.applevel_name is not None:
@@ -68,7 +68,6 @@
else:
pkgroot = cls.__module__
return pkgroot.split('.')[-1]
- get_applevel_name = classmethod(get_applevel_name)
def get(self, name):
space = self.space
@@ -103,7 +102,7 @@
# be normal Functions to get the correct binding behaviour
func = w_value
if (isinstance(func, Function) and
- type(func) is not BuiltinFunction):
+ type(func) is not BuiltinFunction):
try:
bltin = func._builtinversion_
except AttributeError:
@@ -115,7 +114,6 @@
space.setitem(self.w_dict, w_name, w_value)
return w_value
-
def getdict(self, space):
if self.lazy:
for name in self.loaders:
@@ -131,6 +129,7 @@
self.startup_called = False
self._frozen = True
+ @classmethod
def buildloaders(cls):
""" NOT_RPYTHON """
if not hasattr(cls, 'loaders'):
@@ -149,8 +148,6 @@
if '__doc__' not in loaders:
loaders['__doc__'] = cls.get__doc__
- buildloaders = classmethod(buildloaders)
-
def extra_interpdef(self, name, spec):
cls = self.__class__
pkgroot = cls.__module__
@@ -159,21 +156,21 @@
w_obj = loader(space)
space.setattr(space.wrap(self), space.wrap(name), w_obj)
+ @classmethod
def get__doc__(cls, space):
return space.wrap(cls.__doc__)
- get__doc__ = classmethod(get__doc__)
def getinterpevalloader(pkgroot, spec):
""" NOT_RPYTHON """
def ifileloader(space):
- d = {'space' : space}
+ d = {'space':space}
# EVIL HACK (but it works, and this is not RPython :-)
while 1:
try:
value = eval(spec, d)
except NameError, ex:
- name = ex.args[0].split("'")[1] # super-Evil
+ name = ex.args[0].split("'")[1] # super-Evil
if name in d:
raise # propagate the NameError
try:
diff --git a/pypy/interpreter/test/test_app_main.py b/pypy/interpreter/test/test_app_main.py
--- a/pypy/interpreter/test/test_app_main.py
+++ b/pypy/interpreter/test/test_app_main.py
@@ -9,6 +9,11 @@
from pypy.conftest import pypydir
from lib_pypy._pypy_interact import irc_header
+try:
+ import __pypy__
+except ImportError:
+ __pypy__ = None
+
banner = sys.version.splitlines()[0]
app_main = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, 'app_main.py')
@@ -106,6 +111,8 @@
sys.argv[:] = saved_sys_argv
sys.stdout = saved_sys_stdout
sys.stderr = saved_sys_stderr
+ if __pypy__:
+ __pypy__.set_debug(True)
def test_all_combinations_I_can_think_of(self):
self.check([], {}, sys_argv=[''], run_stdin=True)
@@ -133,7 +140,7 @@
self.check(['-S', '-tO', '--info'], {}, output_contains='translation')
self.check(['-S', '-tO', '--version'], {}, output_contains='Python')
self.check(['-S', '-tOV'], {}, output_contains='Python')
- self.check(['--jit', 'foobar', '-S'], {}, sys_argv=[''],
+ self.check(['--jit', 'off', '-S'], {}, sys_argv=[''],
run_stdin=True, no_site=1)
self.check(['-c', 'pass'], {}, sys_argv=['-c'], run_command='pass')
self.check(['-cpass'], {}, sys_argv=['-c'], run_command='pass')
@@ -601,9 +608,7 @@
def run_with_status_code(self, cmdline, senddata='', expect_prompt=False,
expect_banner=False, python_flags='', env=None):
if os.name == 'nt':
- try:
- import __pypy__
- except:
+ if __pypy__ is None:
py.test.skip('app_main cannot run on non-pypy for windows')
cmdline = '%s %s "%s" %s' % (sys.executable, python_flags,
app_main, cmdline)
diff --git a/pypy/interpreter/test/test_function.py b/pypy/interpreter/test/test_function.py
--- a/pypy/interpreter/test/test_function.py
+++ b/pypy/interpreter/test/test_function.py
@@ -1,5 +1,4 @@
-
-import unittest
+import pytest
from pypy.interpreter import eval
from pypy.interpreter.function import Function, Method, descr_function_get
from pypy.interpreter.pycode import PyCode
@@ -187,6 +186,7 @@
raises(
TypeError, func, 42, {'arg1': 23})
+ @pytest.mark.skipif("config.option.runappdirect")
def test_kwargs_nondict_mapping(self):
class Mapping:
def keys(self):
@@ -257,6 +257,14 @@
meth = func.__get__(obj, object)
assert meth() == obj
+ def test_none_get_interaction(self):
+ skip("XXX issue #2083")
+ assert type(None).__repr__(None) == 'None'
+
+ def test_none_get_interaction_2(self):
+ f = None.__repr__
+ assert f() == 'None'
+
def test_no_get_builtin(self):
assert not hasattr(dir, '__get__')
class A(object):
@@ -284,6 +292,7 @@
raises(TypeError, len, s, some_unknown_keyword=s)
raises(TypeError, len, s, s, some_unknown_keyword=s)
+ @pytest.mark.skipif("config.option.runappdirect")
def test_call_error_message(self):
try:
len()
@@ -325,6 +334,7 @@
f = lambda: 42
assert f.func_doc is None
+ @pytest.mark.skipif("config.option.runappdirect")
def test_setstate_called_with_wrong_args(self):
f = lambda: 42
# not sure what it should raise, since CPython doesn't have setstate
@@ -550,6 +560,37 @@
assert A().m == X()
assert X() == A().m
+ @pytest.mark.skipif("config.option.runappdirect")
+ def test_method_identity(self):
+ class A(object):
+ def m(self):
+ pass
+ def n(self):
+ pass
+
+ class B(A):
+ pass
+
+ class X(object):
+ def __eq__(self, other):
+ return True
+
+ a = A()
+ a2 = A()
+ assert a.m is a.m
+ assert id(a.m) == id(a.m)
+ assert a.m is not a.n
+ assert id(a.m) != id(a.n)
+ assert a.m is not a2.m
+ assert id(a.m) != id(a2.m)
+
+ assert A.m is A.m
+ assert id(A.m) == id(A.m)
+ assert A.m is not A.n
+ assert id(A.m) != id(A.n)
+ assert A.m is not B.m
+ assert id(A.m) != id(B.m)
+
class TestMethod:
def setup_method(self, method):
diff --git a/pypy/module/__builtin__/descriptor.py b/pypy/module/__builtin__/descriptor.py
--- a/pypy/module/__builtin__/descriptor.py
+++ b/pypy/module/__builtin__/descriptor.py
@@ -79,6 +79,7 @@
W_Super.typedef = TypeDef(
'super',
__new__ = interp2app(descr_new_super),
+ __thisclass__ = interp_attrproperty_w("w_starttype", W_Super),
__getattribute__ = interp2app(W_Super.getattribute),
__get__ = interp2app(W_Super.get),
__doc__ = """super(type) -> unbound super object
diff --git a/pypy/module/__builtin__/test/test_classobj.py b/pypy/module/__builtin__/test/test_classobj.py
--- a/pypy/module/__builtin__/test/test_classobj.py
+++ b/pypy/module/__builtin__/test/test_classobj.py
@@ -452,7 +452,6 @@
assert a + 1 == 2
assert a + 1.1 == 2
-
def test_binaryop_calls_coerce_always(self):
l = []
class A:
@@ -1076,6 +1075,16 @@
assert (D() > A()) == 'D:A.gt'
assert (D() >= A()) == 'D:A.ge'
+ def test_override___int__(self):
+ class F(float):
+ def __int__(self):
+ return 666
+ f = F(-12.3)
+ assert int(f) == 666
+ # on cpython, this calls float_trunc() in floatobject.c
+ # which ends up calling PyFloat_AS_DOUBLE((PyFloatObject*) f)
+ assert float.__int__(f) == -12
+
class AppTestOldStyleClassBytesDict(object):
def setup_class(cls):
diff --git a/pypy/module/__builtin__/test/test_descriptor.py b/pypy/module/__builtin__/test/test_descriptor.py
--- a/pypy/module/__builtin__/test/test_descriptor.py
+++ b/pypy/module/__builtin__/test/test_descriptor.py
@@ -214,7 +214,7 @@
c = C()
assert C.goo(1) == (C, 1)
assert c.goo(1) == (C, 1)
-
+
assert c.foo(1) == (c, 1)
class D(C):
pass
@@ -238,6 +238,17 @@
meth = classmethod(1).__get__(1)
raises(TypeError, meth)
+ def test_super_thisclass(self):
+ class A(object):
+ pass
+
+ assert super(A, A()).__thisclass__ is A
+
+ class B(A):
+ pass
+
+ assert super(B, B()).__thisclass__ is B
+ assert super(A, B()).__thisclass__ is A
def test_property_docstring(self):
assert property.__doc__.startswith('property')
diff --git a/pypy/module/__pypy__/test/test_signal.py b/pypy/module/__pypy__/test/test_signal.py
--- a/pypy/module/__pypy__/test/test_signal.py
+++ b/pypy/module/__pypy__/test/test_signal.py
@@ -2,7 +2,6 @@
from pypy.module.thread.test.support import GenericTestThread
-
class AppTestMinimal:
spaceconfig = dict(usemodules=['__pypy__'])
diff --git a/pypy/module/_cffi_backend/ctypeptr.py b/pypy/module/_cffi_backend/ctypeptr.py
--- a/pypy/module/_cffi_backend/ctypeptr.py
+++ b/pypy/module/_cffi_backend/ctypeptr.py
@@ -353,10 +353,11 @@
# ____________________________________________________________
-rffi_fdopen = rffi.llexternal("fdopen", [rffi.INT, rffi.CCHARP], rffi.CCHARP,
+FILEP = rffi.COpaquePtr("FILE")
+rffi_fdopen = rffi.llexternal("fdopen", [rffi.INT, rffi.CCHARP], FILEP,
save_err=rffi.RFFI_SAVE_ERRNO)
-rffi_setbuf = rffi.llexternal("setbuf", [rffi.CCHARP, rffi.CCHARP], lltype.Void)
-rffi_fclose = rffi.llexternal("fclose", [rffi.CCHARP], rffi.INT)
+rffi_setbuf = rffi.llexternal("setbuf", [FILEP, rffi.CCHARP], lltype.Void)
+rffi_fclose = rffi.llexternal("fclose", [FILEP], rffi.INT)
class CffiFileObj(object):
_immutable_ = True
@@ -382,4 +383,4 @@
fileobj.cffi_fileobj = CffiFileObj(fd, fileobj.mode)
except OSError, e:
raise wrap_oserror(space, e)
- return fileobj.cffi_fileobj.llf
+ return rffi.cast(rffi.CCHARP, fileobj.cffi_fileobj.llf)
diff --git a/pypy/module/_collections/app_defaultdict.py b/pypy/module/_collections/app_defaultdict.py
--- a/pypy/module/_collections/app_defaultdict.py
+++ b/pypy/module/_collections/app_defaultdict.py
@@ -12,6 +12,7 @@
class defaultdict(dict):
__slots__ = ['default_factory']
+ __module__ = 'collections'
def __init__(self, *args, **kwds):
if len(args) > 0:
diff --git a/pypy/module/_collections/test/test_defaultdict.py b/pypy/module/_collections/test/test_defaultdict.py
--- a/pypy/module/_collections/test/test_defaultdict.py
+++ b/pypy/module/_collections/test/test_defaultdict.py
@@ -14,6 +14,12 @@
d[5].append(44)
assert l == [42, 43] and l2 == [44]
+ def test_module(self):
+ from _collections import defaultdict
+ assert repr(defaultdict) in (
+ "<class 'collections.defaultdict'>", # on PyPy
+ "<type 'collections.defaultdict'>") # on CPython
+
def test_keyerror_without_factory(self):
from _collections import defaultdict
for d1 in [defaultdict(), defaultdict(None)]:
diff --git a/pypy/module/_file/test/test_file_extra.py b/pypy/module/_file/test/test_file_extra.py
--- a/pypy/module/_file/test/test_file_extra.py
+++ b/pypy/module/_file/test/test_file_extra.py
@@ -389,6 +389,7 @@
def test_writelines(self):
import array
+ import sys
fn = self.temptestfile
with file(fn, 'w') as f:
f.writelines(['abc'])
@@ -406,7 +407,10 @@
exc = raises(TypeError, f.writelines, [memoryview('jkl')])
assert str(exc.value) == "writelines() argument must be a sequence of strings"
out = open(fn, 'rb').readlines()[0]
- assert out[0:5] == 'abcd\x00'
+ if sys.byteorder == 'big':
+ assert out[0:7] == 'abc\x00\x00\x00d'
+ else:
+ assert out[0:5] == 'abcd\x00'
assert out[-3:] == 'ghi'
with file(fn, 'wb') as f:
diff --git a/pypy/module/_rawffi/callback.py b/pypy/module/_rawffi/callback.py
--- a/pypy/module/_rawffi/callback.py
+++ b/pypy/module/_rawffi/callback.py
@@ -1,17 +1,23 @@
-
+import sys
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from rpython.rtyper.lltypesystem import lltype, rffi
from pypy.module._rawffi.interp_rawffi import write_ptr
from pypy.module._rawffi.structure import W_Structure
from pypy.module._rawffi.interp_rawffi import (W_DataInstance, letter2tp,
- unwrap_value, unpack_argshapes, got_libffi_error)
+ unwrap_value, unpack_argshapes, got_libffi_error, is_narrow_integer_type,
+ LL_TYPEMAP, NARROW_INTEGER_TYPES)
from rpython.rlib.clibffi import USERDATA_P, CallbackFuncPtr, FUNCFLAG_CDECL
from rpython.rlib.clibffi import ffi_type_void, LibFFIError
from rpython.rlib import rweakref
from pypy.module._rawffi.tracker import tracker
from pypy.interpreter.error import OperationError
from pypy.interpreter import gateway
+from rpython.rlib.unroll import unrolling_iterable
+
+BIGENDIAN = sys.byteorder == 'big'
+
+unroll_narrow_integer_types = unrolling_iterable(NARROW_INTEGER_TYPES)
app = gateway.applevel('''
def tbprint(tb, err):
@@ -42,8 +48,17 @@
args_w[i] = space.wrap(rffi.cast(rffi.ULONG, ll_args[i]))
w_res = space.call(w_callable, space.newtuple(args_w))
if callback_ptr.result is not None: # don't return void
- unwrap_value(space, write_ptr, ll_res, 0,
- callback_ptr.result, w_res)
+ ptr = ll_res
+ letter = callback_ptr.result
+ if BIGENDIAN:
+ # take care of narrow integers!
+ for int_type in unroll_narrow_integer_types:
+ if int_type == letter:
+ T = LL_TYPEMAP[int_type]
+ n = rffi.sizeof(lltype.Signed) - rffi.sizeof(T)
+ ptr = rffi.ptradd(ptr, n)
+ break
+ unwrap_value(space, write_ptr, ptr, 0, letter, w_res)
except OperationError, e:
tbprint(space, space.wrap(e.get_traceback()),
space.wrap(e.errorstr(space)))
diff --git a/pypy/module/_rawffi/interp_rawffi.py b/pypy/module/_rawffi/interp_rawffi.py
--- a/pypy/module/_rawffi/interp_rawffi.py
+++ b/pypy/module/_rawffi/interp_rawffi.py
@@ -1,3 +1,4 @@
+import sys
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, oefmt, wrap_oserror
from pypy.interpreter.gateway import interp2app, unwrap_spec
@@ -19,6 +20,8 @@
from pypy.module._rawffi.buffer import RawFFIBuffer
from pypy.module._rawffi.tracker import tracker
+BIGENDIAN = sys.byteorder == 'big'
+
TYPEMAP = {
# XXX A mess with unsigned/signed/normal chars :-/
'c' : ffi_type_uchar,
@@ -331,10 +334,14 @@
if tracker.DO_TRACING:
ll_buf = rffi.cast(lltype.Signed, self.ll_buffer)
tracker.trace_allocation(ll_buf, self)
+ self._ll_buffer = self.ll_buffer
def getbuffer(self, space):
return space.wrap(rffi.cast(lltype.Unsigned, self.ll_buffer))
+ def buffer_advance(self, n):
+ self.ll_buffer = rffi.ptradd(self.ll_buffer, n)
+
def byptr(self, space):
from pypy.module._rawffi.array import ARRAY_OF_PTRS
array = ARRAY_OF_PTRS.allocate(space, 1)
@@ -342,16 +349,17 @@
return space.wrap(array)
def free(self, space):
- if not self.ll_buffer:
+ if not self._ll_buffer:
raise segfault_exception(space, "freeing NULL pointer")
self._free()
def _free(self):
if tracker.DO_TRACING:
- ll_buf = rffi.cast(lltype.Signed, self.ll_buffer)
+ ll_buf = rffi.cast(lltype.Signed, self._ll_buffer)
tracker.trace_free(ll_buf)
- lltype.free(self.ll_buffer, flavor='raw')
+ lltype.free(self._ll_buffer, flavor='raw')
self.ll_buffer = lltype.nullptr(rffi.VOIDP.TO)
+ self._ll_buffer = self.ll_buffer
def buffer_w(self, space, flags):
return RawFFIBuffer(self)
@@ -432,12 +440,19 @@
space.wrap("cannot directly read value"))
wrap_value._annspecialcase_ = 'specialize:arg(1)'
+NARROW_INTEGER_TYPES = 'cbhiBIH?'
+
+def is_narrow_integer_type(letter):
+ return letter in NARROW_INTEGER_TYPES
class W_FuncPtr(W_Root):
def __init__(self, space, ptr, argshapes, resshape):
self.ptr = ptr
self.argshapes = argshapes
self.resshape = resshape
+ self.narrow_integer = False
+ if resshape is not None:
+ self.narrow_integer = is_narrow_integer_type(resshape.itemcode.lower())
def getbuffer(self, space):
return space.wrap(rffi.cast(lltype.Unsigned, self.ptr.funcsym))
@@ -497,6 +512,10 @@
result = self.resshape.allocate(space, 1, autofree=True)
# adjust_return_size() was used here on result.ll_buffer
self.ptr.call(args_ll, result.ll_buffer)
+ if BIGENDIAN and self.narrow_integer:
+ # we get a 8 byte value in big endian
+ n = rffi.sizeof(lltype.Signed) - result.shape.size
+ result.buffer_advance(n)
return space.wrap(result)
else:
self.ptr.call(args_ll, lltype.nullptr(rffi.VOIDP.TO))
diff --git a/pypy/module/_rawffi/structure.py b/pypy/module/_rawffi/structure.py
--- a/pypy/module/_rawffi/structure.py
+++ b/pypy/module/_rawffi/structure.py
@@ -18,6 +18,9 @@
from rpython.rlib.rarithmetic import intmask, signedtype, r_uint, \
r_ulonglong
from rpython.rtyper.lltypesystem import lltype, rffi
+import sys
+
+IS_BIG_ENDIAN = sys.byteorder == 'big'
@@ -114,20 +117,32 @@
size += intmask(fieldsize)
bitsizes.append(fieldsize)
elif field_type == NEW_BITFIELD:
- bitsizes.append((bitsize << 16) + bitoffset)
+ if IS_BIG_ENDIAN:
+ off = last_size - bitoffset - bitsize
+ else:
+ off = bitoffset
+ bitsizes.append((bitsize << 16) + off)
bitoffset = bitsize
size = round_up(size, fieldalignment)
pos.append(size)
size += fieldsize
elif field_type == CONT_BITFIELD:
- bitsizes.append((bitsize << 16) + bitoffset)
+ if IS_BIG_ENDIAN:
+ off = last_size - bitoffset - bitsize
+ else:
+ off = bitoffset
+ bitsizes.append((bitsize << 16) + off)
bitoffset += bitsize
# offset is already updated for the NEXT field
pos.append(size - fieldsize)
elif field_type == EXPAND_BITFIELD:
size += fieldsize - last_size / 8
last_size = fieldsize * 8
- bitsizes.append((bitsize << 16) + bitoffset)
+ if IS_BIG_ENDIAN:
+ off = last_size - bitoffset - bitsize
+ else:
+ off = bitoffset
+ bitsizes.append((bitsize << 16) + off)
bitoffset += bitsize
# offset is already updated for the NEXT field
pos.append(size - fieldsize)
diff --git a/pypy/module/_rawffi/test/test__rawffi.py b/pypy/module/_rawffi/test/test__rawffi.py
--- a/pypy/module/_rawffi/test/test__rawffi.py
+++ b/pypy/module/_rawffi/test/test__rawffi.py
@@ -704,7 +704,6 @@
def compare(a, b):
a1 = _rawffi.Array('i').fromaddress(_rawffi.Array('P').fromaddress(a, 1)[0], 1)
a2 = _rawffi.Array('i').fromaddress(_rawffi.Array('P').fromaddress(b, 1)[0], 1)
- print "comparing", a1[0], "with", a2[0]
if a1[0] not in [1,2,3,4] or a2[0] not in [1,2,3,4]:
bogus_args.append((a1[0], a2[0]))
if a1[0] > a2[0]:
@@ -715,7 +714,7 @@
a2[0] = len(ll_to_sort)
a3 = _rawffi.Array('l')(1)
a3[0] = struct.calcsize('i')
- cb = _rawffi.CallbackPtr(compare, ['P', 'P'], 'i')
+ cb = _rawffi.CallbackPtr(compare, ['P', 'P'], 'l')
a4 = cb.byptr()
qsort(a1, a2, a3, a4)
res = [ll_to_sort[i] for i in range(len(ll_to_sort))]
@@ -896,11 +895,21 @@
b = _rawffi.Array('c').fromaddress(a.buffer, 38)
if sys.maxunicode > 65535:
# UCS4 build
- assert b[0] == 'x'
- assert b[1] == '\x00'
- assert b[2] == '\x00'
- assert b[3] == '\x00'
- assert b[4] == 'y'
+ if sys.byteorder == 'big':
+ assert b[0] == '\x00'
+ assert b[1] == '\x00'
+ assert b[2] == '\x00'
+ assert b[3] == 'x'
+ assert b[4] == '\x00'
+ assert b[5] == '\x00'
+ assert b[6] == '\x00'
+ assert b[7] == 'y'
+ else:
+ assert b[0] == 'x'
+ assert b[1] == '\x00'
+ assert b[2] == '\x00'
+ assert b[3] == '\x00'
+ assert b[4] == 'y'
else:
# UCS2 build
assert b[0] == 'x'
diff --git a/pypy/module/_rawffi/test/test_struct.py b/pypy/module/_rawffi/test/test_struct.py
--- a/pypy/module/_rawffi/test/test_struct.py
+++ b/pypy/module/_rawffi/test/test_struct.py
@@ -1,4 +1,4 @@
-
+import sys
from pypy.module._rawffi.structure import size_alignment_pos
from pypy.module._rawffi.interp_rawffi import TYPEMAP, letter2tp
@@ -63,4 +63,7 @@
for (name, t, size) in fields])
assert size == 8
assert pos == [0, 0, 0]
- assert bitsizes == [0x10000, 0x3e0001, 0x1003f]
+ if sys.byteorder == 'little':
+ assert bitsizes == [0x10000, 0x3e0001, 0x1003f]
+ else:
+ assert bitsizes == [0x1003f, 0x3e0001, 0x10000]
diff --git a/pypy/module/_sre/interp_sre.py b/pypy/module/_sre/interp_sre.py
--- a/pypy/module/_sre/interp_sre.py
+++ b/pypy/module/_sre/interp_sre.py
@@ -7,6 +7,7 @@
from pypy.interpreter.error import OperationError
from rpython.rlib.rarithmetic import intmask
from rpython.rlib import jit
+from rpython.rlib.rstring import StringBuilder, UnicodeBuilder
# ____________________________________________________________
#
@@ -36,6 +37,8 @@
if 0 <= start <= end:
if isinstance(ctx, rsre_core.BufMatchContext):
return space.wrap(ctx._buffer.getslice(start, end, 1, end-start))
+ if isinstance(ctx, rsre_core.StrMatchContext):
+ return space.wrap(ctx._string[start:end])
elif isinstance(ctx, rsre_core.UnicodeMatchContext):
return space.wrap(ctx._unicodestr[start:end])
else:
@@ -98,8 +101,8 @@
space.wrap("cannot copy this pattern object"))
def make_ctx(self, w_string, pos=0, endpos=sys.maxint):
- """Make a BufMatchContext or a UnicodeMatchContext for searching
- in the given w_string object."""
+ """Make a StrMatchContext, BufMatchContext or a UnicodeMatchContext for
+ searching in the given w_string object."""
space = self.space
if pos < 0:
pos = 0
@@ -113,6 +116,14 @@
endpos = len(unicodestr)
return rsre_core.UnicodeMatchContext(self.code, unicodestr,
pos, endpos, self.flags)
+ elif space.isinstance_w(w_string, space.w_str):
+ str = space.str_w(w_string)
+ if pos > len(str):
+ pos = len(str)
+ if endpos > len(str):
+ endpos = len(str)
+ return rsre_core.StrMatchContext(self.code, str,
+ pos, endpos, self.flags)
else:
buf = space.readbuf_w(w_string)
size = buf.getlength()
@@ -216,6 +227,11 @@
def subx(self, w_ptemplate, w_string, count):
space = self.space
+ # use a (much faster) string/unicode builder if w_ptemplate and
+ # w_string are both string or both unicode objects, and if w_ptemplate
+ # is a literal
+ use_builder = False
+ filter_as_unicode = filter_as_string = None
if space.is_true(space.callable(w_ptemplate)):
w_filter = w_ptemplate
filter_is_callable = True
@@ -223,6 +239,8 @@
if space.isinstance_w(w_ptemplate, space.w_unicode):
filter_as_unicode = space.unicode_w(w_ptemplate)
literal = u'\\' not in filter_as_unicode
+ use_builder = (
+ space.isinstance_w(w_string, space.w_unicode) and literal)
else:
try:
filter_as_string = space.str_w(w_ptemplate)
@@ -232,6 +250,8 @@
literal = False
else:
literal = '\\' not in filter_as_string
+ use_builder = (
+ space.isinstance_w(w_string, space.w_str) and literal)
if literal:
w_filter = w_ptemplate
filter_is_callable = False
@@ -242,19 +262,44 @@
space.wrap(self), w_ptemplate)
filter_is_callable = space.is_true(space.callable(w_filter))
#
+ # XXX this is a bit of a mess, but it improves performance a lot
ctx = self.make_ctx(w_string)
- sublist_w = []
+ sublist_w = strbuilder = unicodebuilder = None
+ if use_builder:
+ if filter_as_unicode is not None:
+ unicodebuilder = UnicodeBuilder(ctx.end)
+ else:
+ assert filter_as_string is not None
+ strbuilder = StringBuilder(ctx.end)
+ else:
+ sublist_w = []
n = last_pos = 0
while not count or n < count:
+ sub_jitdriver.jit_merge_point(
+ self=self,
+ use_builder=use_builder,
+ filter_is_callable=filter_is_callable,
+ filter_type=type(w_filter),
+ ctx=ctx,
+ w_filter=w_filter,
+ strbuilder=strbuilder,
+ unicodebuilder=unicodebuilder,
+ filter_as_string=filter_as_string,
+ filter_as_unicode=filter_as_unicode,
+ count=count,
+ w_string=w_string,
+ n=n, last_pos=last_pos, sublist_w=sublist_w
+ )
+ space = self.space
if not searchcontext(space, ctx):
break
if last_pos < ctx.match_start:
- sublist_w.append(slice_w(space, ctx, last_pos,
- ctx.match_start, space.w_None))
+ _sub_append_slice(
+ ctx, space, use_builder, sublist_w,
+ strbuilder, unicodebuilder, last_pos, ctx.match_start)
start = ctx.match_end
if start == ctx.match_start:
start += 1
- nextctx = ctx.fresh_copy(start)
if not (last_pos == ctx.match_start
== ctx.match_end and n > 0):
# the above ignores empty matches on latest position
@@ -262,28 +307,71 @@
w_match = self.getmatch(ctx, True)
w_piece = space.call_function(w_filter, w_match)
if not space.is_w(w_piece, space.w_None):
+ assert strbuilder is None and unicodebuilder is None
+ assert not use_builder
sublist_w.append(w_piece)
else:
- sublist_w.append(w_filter)
+ if use_builder:
+ if strbuilder is not None:
+ assert filter_as_string is not None
+ strbuilder.append(filter_as_string)
+ else:
+ assert unicodebuilder is not None
+ assert filter_as_unicode is not None
+ unicodebuilder.append(filter_as_unicode)
+ else:
+ sublist_w.append(w_filter)
last_pos = ctx.match_end
n += 1
elif last_pos >= ctx.end:
break # empty match at the end: finished
- ctx = nextctx
+ ctx.reset(start)
if last_pos < ctx.end:
- sublist_w.append(slice_w(space, ctx, last_pos, ctx.end,
- space.w_None))
+ _sub_append_slice(ctx, space, use_builder, sublist_w,
+ strbuilder, unicodebuilder, last_pos, ctx.end)
+ if use_builder:
+ if strbuilder is not None:
+ return space.wrap(strbuilder.build()), n
+ else:
+ assert unicodebuilder is not None
+ return space.wrap(unicodebuilder.build()), n
+ else:
+ if space.isinstance_w(w_string, space.w_unicode):
+ w_emptystr = space.wrap(u'')
+ else:
+ w_emptystr = space.wrap('')
+ w_item = space.call_method(w_emptystr, 'join',
+ space.newlist(sublist_w))
+ return w_item, n
- if space.isinstance_w(w_string, space.w_unicode):
- w_emptystr = space.wrap(u'')
- else:
- w_emptystr = space.wrap('')
- w_item = space.call_method(w_emptystr, 'join',
- space.newlist(sublist_w))
- return w_item, n
+sub_jitdriver = jit.JitDriver(
+ reds="""count n last_pos
+ ctx w_filter
+ strbuilder unicodebuilder
+ filter_as_string
+ filter_as_unicode
+ w_string sublist_w
+ self""".split(),
+ greens=["filter_is_callable", "use_builder", "filter_type", "ctx.pattern"])
+def _sub_append_slice(ctx, space, use_builder, sublist_w,
+ strbuilder, unicodebuilder, start, end):
+ if use_builder:
+ if isinstance(ctx, rsre_core.BufMatchContext):
+ assert strbuilder is not None
+ return strbuilder.append(ctx._buffer.getslice(start, end, 1, end-start))
+ if isinstance(ctx, rsre_core.StrMatchContext):
+ assert strbuilder is not None
+ return strbuilder.append_slice(ctx._string, start, end)
+ elif isinstance(ctx, rsre_core.UnicodeMatchContext):
+ assert unicodebuilder is not None
+ return unicodebuilder.append_slice(ctx._unicodestr, start, end)
+ assert 0, "unreachable"
+ else:
+ sublist_w.append(slice_w(space, ctx, start, end, space.w_None))
+
@unwrap_spec(flags=int, groups=int, w_groupindex=WrappedDefault(None),
w_indexgroup=WrappedDefault(None))
def SRE_Pattern__new__(space, w_subtype, w_pattern, flags, w_code,
@@ -482,6 +570,8 @@
ctx = self.ctx
if isinstance(ctx, rsre_core.BufMatchContext):
return space.wrap(ctx._buffer.as_str())
+ elif isinstance(ctx, rsre_core.StrMatchContext):
+ return space.wrap(ctx._string)
elif isinstance(ctx, rsre_core.UnicodeMatchContext):
return space.wrap(ctx._unicodestr)
else:
diff --git a/pypy/module/_vmprof/conftest.py b/pypy/module/_vmprof/conftest.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/_vmprof/conftest.py
@@ -0,0 +1,6 @@
+import py, platform
+
+def pytest_collect_directory(path, parent):
+ if platform.machine() == 's390x':
+ py.test.skip("zarch tests skipped")
+pytest_collect_file = pytest_collect_directory
diff --git a/pypy/module/_vmprof/interp_vmprof.py b/pypy/module/_vmprof/interp_vmprof.py
--- a/pypy/module/_vmprof/interp_vmprof.py
+++ b/pypy/module/_vmprof/interp_vmprof.py
@@ -60,10 +60,10 @@
Must be smaller than 1.0
"""
w_modules = space.sys.get('modules')
- if space.contains_w(w_modules, space.wrap('_continuation')):
- space.warn(space.wrap("Using _continuation/greenlet/stacklet together "
- "with vmprof will crash"),
- space.w_RuntimeWarning)
+ #if space.contains_w(w_modules, space.wrap('_continuation')):
+ # space.warn(space.wrap("Using _continuation/greenlet/stacklet together "
+ # "with vmprof will crash"),
+ # space.w_RuntimeWarning)
try:
rvmprof.enable(fileno, period)
except rvmprof.VMProfError, e:
diff --git a/pypy/module/_vmprof/test/test__vmprof.py b/pypy/module/_vmprof/test/test__vmprof.py
--- a/pypy/module/_vmprof/test/test__vmprof.py
+++ b/pypy/module/_vmprof/test/test__vmprof.py
@@ -5,14 +5,15 @@
class AppTestVMProf(object):
def setup_class(cls):
cls.space = gettestobjspace(usemodules=['_vmprof', 'struct'])
- cls.tmpfile = udir.join('test__vmprof.1').open('wb')
- cls.w_tmpfileno = cls.space.wrap(cls.tmpfile.fileno())
- cls.w_tmpfilename = cls.space.wrap(cls.tmpfile.name)
- cls.tmpfile2 = udir.join('test__vmprof.2').open('wb')
- cls.w_tmpfileno2 = cls.space.wrap(cls.tmpfile2.fileno())
- cls.w_tmpfilename2 = cls.space.wrap(cls.tmpfile2.name)
+ cls.w_tmpfilename = cls.space.wrap(str(udir.join('test__vmprof.1')))
+ cls.w_tmpfilename2 = cls.space.wrap(str(udir.join('test__vmprof.2')))
def test_import_vmprof(self):
+ tmpfile = open(self.tmpfilename, 'wb')
+ tmpfileno = tmpfile.fileno()
+ tmpfile2 = open(self.tmpfilename2, 'wb')
+ tmpfileno2 = tmpfile2.fileno()
+
import struct, sys
WORD = struct.calcsize('l')
@@ -45,7 +46,7 @@
return count
import _vmprof
- _vmprof.enable(self.tmpfileno, 0.01)
+ _vmprof.enable(tmpfileno, 0.01)
_vmprof.disable()
s = open(self.tmpfilename, 'rb').read()
no_of_codes = count(s)
@@ -56,7 +57,7 @@
pass
""" in d
- _vmprof.enable(self.tmpfileno2, 0.01)
+ _vmprof.enable(tmpfileno2, 0.01)
exec """def foo2():
pass
diff --git a/pypy/module/cppyy/src/dummy_backend.cxx b/pypy/module/cppyy/src/dummy_backend.cxx
--- a/pypy/module/cppyy/src/dummy_backend.cxx
+++ b/pypy/module/cppyy/src/dummy_backend.cxx
@@ -390,7 +390,7 @@
((dummy::cppyy_test_data*)self)->destroy_arrays();
} else if (idx == s_methods["cppyy_test_data::set_bool"]) {
assert(self && nargs == 1);
- ((dummy::cppyy_test_data*)self)->set_bool((bool)((CPPYY_G__value*)args)[0].obj.in);
+ ((dummy::cppyy_test_data*)self)->set_bool((bool)((CPPYY_G__value*)args)[0].obj.i);
} else if (idx == s_methods["cppyy_test_data::set_char"]) {
assert(self && nargs == 1);
More information about the pypy-commit
mailing list