[pypy-commit] pypy cpyext-ext: merge default into branch
mattip
pypy.commits at gmail.com
Wed Mar 9 14:32:48 EST 2016
Author: mattip <matti.picus at gmail.com>
Branch: cpyext-ext
Changeset: r82920:48d4c2cf24e3
Date: 2016-03-09 21:18 +0200
http://bitbucket.org/pypy/pypy/changeset/48d4c2cf24e3/
Log: merge default into branch
diff too long, truncating to 2000 out of 4911 lines
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
@@ -41,29 +41,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
@@ -72,8 +72,8 @@
Romain Guillebert
Leonardo Santagada
Seo Sanghyeon
+ Ronny Pfannschmidt
Justin Peel
- Ronny Pfannschmidt
David Edelsohn
Anders Hammarquist
Jakub Gustak
@@ -95,6 +95,7 @@
Tyler Wade
Michael Foord
Stephan Diehl
+ Vincent Legoll
Stefan Schwarzer
Valentino Volonghi
Tomek Meka
@@ -105,9 +106,9 @@
Jean-Paul Calderone
Timo Paulssen
Squeaky
+ Marius Gedminas
Alexandre Fayolle
Simon Burton
- Marius Gedminas
Martin Matusiak
Konstantin Lopuhin
Wenzhu Man
@@ -116,16 +117,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
@@ -134,14 +139,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
@@ -153,6 +156,8 @@
Lukas Renggli
Guenter Jantzen
Ned Batchelder
+ Tim Felgentreff
+ Anton Gulenko
Amit Regmi
Ben Young
Nicolas Chauvat
@@ -162,12 +167,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
@@ -191,33 +196,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
@@ -225,6 +230,7 @@
Jakub Stasiak
Nathan Taylor
Vladimir Kryachko
+ Omer Katz
Jacek Generowicz
Alejandro J. Cura
Jacob Oscarson
@@ -234,11 +240,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
@@ -250,20 +258,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
@@ -273,6 +282,7 @@
Christopher Armstrong
Michael Hudson-Doyle
Anders Sigfridsson
+ Nikolay Zinov
Yasir Suhail
Jason Michalski
rafalgalczynski at gmail.com
@@ -282,6 +292,7 @@
Gustavo Niemeyer
Stephan Busemann
Rafał Gałczyński
+ Matt Bogosian
Christian Muirhead
Berker Peksag
James Lan
@@ -316,9 +327,9 @@
Stefan Marr
jiaaro
Mads Kiilerich
- Richard Lancaster
opassembler.py
Antony Lee
+ Jason Madden
Yaroslav Fedevych
Jim Hunziker
Markus Unterwaditzer
@@ -327,6 +338,7 @@
squeaky
Zearin
soareschen
+ Jonas Pfannschmidt
Kurt Griffiths
Mike Bayer
Matthew Miller
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/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -170,12 +170,8 @@
cmdline="--translationmodules",
suggests=[("objspace.allworkingmodules", False)]),
- BoolOption("usepycfiles", "Write and read pyc files when importing",
- default=True),
-
BoolOption("lonepycfiles", "Import pyc files with no matching py file",
- default=False,
- requires=[("objspace.usepycfiles", True)]),
+ default=False),
StrOption("soabi",
"Tag to differentiate extension modules built for different Python interpreters",
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
@@ -1,5 +1,20 @@
-Making a PyPy Release
-=====================
+The PyPy Release Process
+========================
+
+Release Policy
+++++++++++++++
+
+We try to create a stable release a few times a year. These are released on
+a branch named like release-2.x or release-4.x, and each release is tagged,
+for instance release-4.0.1.
+
+After release, inevitably there are bug fixes. It is the responsibility of
+the commiter who fixes a bug to make sure this fix is on the release branch,
+so that we can then create a tagged bug-fix release, which will hopefully
+happen more often than stable releases.
+
+How to Create a PyPy Release
+++++++++++++++++++++++++++++
Overview
--------
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/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/tool/makecontributor.py b/pypy/doc/tool/makecontributor.py
--- a/pypy/doc/tool/makecontributor.py
+++ b/pypy/doc/tool/makecontributor.py
@@ -72,6 +72,7 @@
'Anton Gulenko':['anton gulenko', 'anton_gulenko'],
'Richard Lancaster':['richardlancaster'],
'William Leslie':['William ML Leslie'],
+ 'Spenser Bauman':['Spenser Andrew Bauman'],
}
alias_map = {}
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,7 @@
=========================
-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.
-
-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.
\ No newline at end of file
diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -277,7 +277,6 @@
if config.translation.sandbox:
config.objspace.lonepycfiles = False
- config.objspace.usepycfiles = False
config.translating = True
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
@@ -133,7 +133,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')
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/_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/_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/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/cpyext/__init__.py b/pypy/module/cpyext/__init__.py
--- a/pypy/module/cpyext/__init__.py
+++ b/pypy/module/cpyext/__init__.py
@@ -34,7 +34,7 @@
import pypy.module.cpyext.pyerrors
import pypy.module.cpyext.typeobject
import pypy.module.cpyext.object
-import pypy.module.cpyext.stringobject
+import pypy.module.cpyext.bytesobject
import pypy.module.cpyext.tupleobject
import pypy.module.cpyext.setobject
import pypy.module.cpyext.dictobject
diff --git a/pypy/module/cpyext/stringobject.py b/pypy/module/cpyext/bytesobject.py
rename from pypy/module/cpyext/stringobject.py
rename to pypy/module/cpyext/bytesobject.py
diff --git a/pypy/module/cpyext/include/patchlevel.h b/pypy/module/cpyext/include/patchlevel.h
--- a/pypy/module/cpyext/include/patchlevel.h
+++ b/pypy/module/cpyext/include/patchlevel.h
@@ -29,8 +29,8 @@
#define PY_VERSION "2.7.10"
/* PyPy version as a string */
-#define PYPY_VERSION "4.1.0-alpha0"
-#define PYPY_VERSION_NUM 0x04010000
+#define PYPY_VERSION "5.1.0-alpha0"
+#define PYPY_VERSION_NUM 0x05010000
/* Defined to mean a PyPy where cpyext holds more regular references
to PyObjects, e.g. staying alive as long as the internal PyPy object
diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -192,7 +192,7 @@
def from_ref(space, ref):
"""
Finds the interpreter object corresponding to the given reference. If the
- object is not yet realized (see stringobject.py), creates it.
+ object is not yet realized (see bytesobject.py), creates it.
"""
assert is_pyobj(ref)
if not ref:
diff --git a/pypy/module/cpyext/structmember.py b/pypy/module/cpyext/structmember.py
--- a/pypy/module/cpyext/structmember.py
+++ b/pypy/module/cpyext/structmember.py
@@ -6,7 +6,7 @@
from pypy.module.cpyext.intobject import PyInt_AsLong, PyInt_AsUnsignedLong
from pypy.module.cpyext.pyerrors import PyErr_Occurred
from pypy.module.cpyext.pyobject import PyObject, Py_DecRef, from_ref, make_ref
-from pypy.module.cpyext.stringobject import (
+from pypy.module.cpyext.bytesobject import (
PyString_FromString, PyString_FromStringAndSize)
from pypy.module.cpyext.floatobject import PyFloat_AsDouble
from pypy.module.cpyext.longobject import (
diff --git a/pypy/module/cpyext/test/test_stringobject.py b/pypy/module/cpyext/test/test_bytesobject.py
rename from pypy/module/cpyext/test/test_stringobject.py
rename to pypy/module/cpyext/test/test_bytesobject.py
--- a/pypy/module/cpyext/test/test_stringobject.py
+++ b/pypy/module/cpyext/test/test_bytesobject.py
@@ -1,7 +1,7 @@
from rpython.rtyper.lltypesystem import rffi, lltype
from pypy.module.cpyext.test.test_api import BaseApiTest
from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
-from pypy.module.cpyext.stringobject import new_empty_str, PyStringObject
+from pypy.module.cpyext.bytesobject import new_empty_str, PyStringObject
from pypy.module.cpyext.api import PyObjectP, PyObject, Py_ssize_tP
from pypy.module.cpyext.pyobject import Py_DecRef, from_ref, make_ref
from pypy.module.cpyext.typeobjectdefs import PyTypeObjectPtr
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -422,7 +422,7 @@
@cpython_api([PyObject, Py_ssize_t, rffi.VOIDPP], lltype.Signed,
header=None, error=-1)
def str_getreadbuffer(space, w_str, segment, ref):
- from pypy.module.cpyext.stringobject import PyString_AsString
+ from pypy.module.cpyext.bytesobject import PyString_AsString
if segment != 0:
raise OperationError(space.w_SystemError, space.wrap
("accessing non-existent string segment"))
@@ -435,7 +435,7 @@
@cpython_api([PyObject, Py_ssize_t, rffi.CCHARPP], lltype.Signed,
header=None, error=-1)
def str_getcharbuffer(space, w_str, segment, ref):
- from pypy.module.cpyext.stringobject import PyString_AsString
+ from pypy.module.cpyext.bytesobject import PyString_AsString
if segment != 0:
raise OperationError(space.w_SystemError, space.wrap
("accessing non-existent string segment"))
@@ -552,7 +552,7 @@
w_typename = space.getattr(w_type, space.wrap('__name__'))
heaptype = rffi.cast(PyHeapTypeObject, pto)
heaptype.c_ht_name = make_ref(space, w_typename)
- from pypy.module.cpyext.stringobject import PyString_AsString
+ from pypy.module.cpyext.bytesobject import PyString_AsString
pto.c_tp_name = PyString_AsString(space, heaptype.c_ht_name)
else:
pto.c_tp_name = rffi.str2charp(w_type.name)
diff --git a/pypy/module/cpyext/unicodeobject.py b/pypy/module/cpyext/unicodeobject.py
--- a/pypy/module/cpyext/unicodeobject.py
+++ b/pypy/module/cpyext/unicodeobject.py
@@ -9,7 +9,7 @@
from pypy.module.cpyext.pyobject import (
PyObject, PyObjectP, Py_DecRef, make_ref, from_ref, track_reference,
make_typedescr, get_typedescr, as_pyobj)
-from pypy.module.cpyext.stringobject import PyString_Check
+from pypy.module.cpyext.bytesobject import PyString_Check
from pypy.module.sys.interp_encoding import setdefaultencoding
from pypy.module._codecs.interp_codecs import CodecState
from pypy.objspace.std import unicodeobject
@@ -17,7 +17,7 @@
from rpython.tool.sourcetools import func_renamer
import sys
-## See comment in stringobject.py.
+## See comment in bytesobject.py.
PyUnicodeObjectStruct = lltype.ForwardReference()
PyUnicodeObject = lltype.Ptr(PyUnicodeObjectStruct)
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -85,7 +85,7 @@
# The "imp" module does not respect this, and is allowed to find
# lone .pyc files.
# check the .pyc file
- if space.config.objspace.usepycfiles and space.config.objspace.lonepycfiles:
+ if space.config.objspace.lonepycfiles:
pycfile = filepart + ".pyc"
if file_exists(pycfile):
# existing .pyc file
@@ -888,17 +888,11 @@
"""
w = space.wrap
- if space.config.objspace.usepycfiles:
More information about the pypy-commit
mailing list