[pypy-commit] pypy py3k: Make test_venv testable by itself

2016-07-23 Thread rguillebert
Author: Romain Guillebert 
Branch: py3k
Changeset: r85819:2bff288c98b0
Date: 2016-07-23 12:11 +0200
http://bitbucket.org/pypy/pypy/changeset/2bff288c98b0/

Log:Make test_venv testable by itself

diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -452,7 +452,7 @@
 RegrTest('test_userstring.py', core=True),
 RegrTest('test_uu.py'),
 RegrTest('test_uuid.py'),
-RegrTest('test_venv.py'),
+RegrTest('test_venv.py', usemodules="struct"),
 RegrTest('test_wait3.py', usemodules="thread"),
 RegrTest('test_wait4.py', usemodules="thread"),
 RegrTest('test_warnings.py', core=True),
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: Fix test_identity_vs_id_primitives for Python 3

2016-07-23 Thread rguillebert
Author: Romain Guillebert 
Branch: py3k
Changeset: r85818:e7eb47c7e7d7
Date: 2016-07-23 11:41 +0200
http://bitbucket.org/pypy/pypy/changeset/e7eb47c7e7d7/

Log:Fix test_identity_vs_id_primitives for Python 3

diff --git a/pypy/objspace/std/test/test_obj.py 
b/pypy/objspace/std/test/test_obj.py
--- a/pypy/objspace/std/test/test_obj.py
+++ b/pypy/objspace/std/test/test_obj.py
@@ -211,11 +211,10 @@
 
 def test_identity_vs_id_primitives(self):
 import sys
-l = range(-10, 10, 2)
+l = list(range(-10, 10, 2))
 for i in [0, 1, 3]:
 l.append(float(i))
 l.append(i + 0.1)
-l.append(long(i))
 l.append(i + sys.maxsize)
 l.append(i - sys.maxsize)
 l.append(i + 1j)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Fix typo

2015-02-04 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5501:74934f466440
Date: 2015-02-04 20:42 +0100
http://bitbucket.org/pypy/extradoc/changeset/74934f466440/

Log:Fix typo

diff --git a/talk/fosdem2015/talk.pdf b/talk/fosdem2015/talk.pdf
index 
e1d849071a9ecfed8044921f817cc8476db0d0a6..a64540c5df6d1e7d57d78b1feda51dc7eeb26e53
GIT binary patch

[cut]

diff --git a/talk/fosdem2015/talk.rst b/talk/fosdem2015/talk.rst
--- a/talk/fosdem2015/talk.rst
+++ b/talk/fosdem2015/talk.rst
@@ -54,7 +54,7 @@
 Current situation (3/3)
 ---
 
-* It's pretty hard to switch between implementations because of C extensions ()
+* It's pretty hard to switch between implementations because of C extensions
 
 * C extensions are very useful but CPython can't evolve because of them
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add a conclusion

2015-01-30 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5495:40c8ae88cd7e
Date: 2015-01-30 16:49 +0100
http://bitbucket.org/pypy/extradoc/changeset/40c8ae88cd7e/

Log:Add a conclusion

diff --git a/talk/fosdem2015/talk.pdf b/talk/fosdem2015/talk.pdf
index 
9910de377ab5fdf9a9af5f634ed4b9cbd35c0954..e1d849071a9ecfed8044921f817cc8476db0d0a6
GIT binary patch

[cut]

diff --git a/talk/fosdem2015/talk.rst b/talk/fosdem2015/talk.rst
--- a/talk/fosdem2015/talk.rst
+++ b/talk/fosdem2015/talk.rst
@@ -64,7 +64,7 @@
 
 |pause|
 
-* More competition between implementations would benefit us
+* More competition between implementations would benefit everybody
 
 Why can't other implementations implement the C API
 ---
@@ -146,7 +146,18 @@
 
 * PyMetabiosis demo
 
-* This will allow us to bring the entire scientific stack in a very short 
amount of time
+* This should give PyPy another way to interact with CPython C extensions, 
better suited for bringing e.g. the entire scientific stack in
+
+Summary
+---
+
+* We can do better
+
+* PyPy is working on getting even better
+
+* Making an alternative implementation friendly ecosystem is quite hard
+
+* But rewarding
 
 Thank you
 -
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Almost finished

2015-01-30 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5494:aa114ba3adbb
Date: 2015-01-30 12:43 +0100
http://bitbucket.org/pypy/extradoc/changeset/aa114ba3adbb/

Log:Almost finished

diff --git a/talk/fosdem2015/talk.pdf b/talk/fosdem2015/talk.pdf
index 
d6bd101dba4bda4ec0c1ac9ea2c519ecd0b8d916..9910de377ab5fdf9a9af5f634ed4b9cbd35c0954
GIT binary patch

[cut]

diff --git a/talk/fosdem2015/talk.rst b/talk/fosdem2015/talk.rst
--- a/talk/fosdem2015/talk.rst
+++ b/talk/fosdem2015/talk.rst
@@ -117,6 +117,8 @@
 
 * Competes with other fast dynamic languages
 
+* Pay the cost of what you use
+
 CFFI
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add my fosdem2015 talk (WIP)

2015-01-29 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5492:48a04232f5e5
Date: 2015-01-29 22:04 +0100
http://bitbucket.org/pypy/extradoc/changeset/48a04232f5e5/

Log:Add my fosdem2015 talk (WIP)

diff --git a/talk/fosdem2015/Makefile b/talk/fosdem2015/Makefile
new file mode 100644
--- /dev/null
+++ b/talk/fosdem2015/Makefile
@@ -0,0 +1,18 @@
+# you can find rst2beamer.py here:
+# https://bitbucket.org/antocuni/env/raw/default/bin/rst2beamer.py
+
+# WARNING: to work, it needs this patch for docutils
+# 
https://sourceforge.net/tracker/?func=detailatid=422032aid=1459707group_id=38414
+
+talk.pdf: talk.rst author.latex stylesheet.latex
+   python `which rst2beamer.py` --stylesheet=stylesheet.latex 
--documentoptions=14pt talk.rst talk.latex || exit
+   #/home/antocuni/.virtualenvs/rst2beamer/bin/python `which 
rst2beamer.py` --stylesheet=stylesheet.latex --documentoptions=14pt talk.rst 
talk.latex || exit
+   sed 's/\\date{}/\\input{author.latex}/' -i talk.latex || exit
+   #sed 's/\\maketitle/\\input{title.latex}/' -i talk.latex || exit
+   pdflatex talk.latex  || exit
+
+view: talk.pdf
+   evince talk.pdf 
+
+xpdf: talk.pdf
+   xpdf talk.pdf 
diff --git a/talk/fosdem2015/author.latex b/talk/fosdem2015/author.latex
new file mode 100644
--- /dev/null
+++ b/talk/fosdem2015/author.latex
@@ -0,0 +1,9 @@
+\definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0}
+
+\title[PyPy and the future of the Python ecosystem]{PyPy and the future of the 
Python ecosystem}
+\author[rguillebert]
+{Romain Guillebert\\
+\includegraphics[width=80px]{../img/py-web-new.png}}
+
+\institute{Fosdem 2015}
+\date{January 31st, 2015}
diff --git a/talk/fosdem2015/beamerdefs.txt b/talk/fosdem2015/beamerdefs.txt
new file mode 100644
--- /dev/null
+++ b/talk/fosdem2015/beamerdefs.txt
@@ -0,0 +1,108 @@
+.. colors
+.. ===
+
+.. role:: green
+.. role:: red
+
+
+.. general useful commands
+.. ===
+
+.. |pause| raw:: latex
+
+   \pause
+
+.. |small| raw:: latex
+
+   {\small
+
+.. |end_small| raw:: latex
+
+   }
+
+.. |scriptsize| raw:: latex
+
+   {\scriptsize
+
+.. |end_scriptsize| raw:: latex
+
+   }
+
+.. |strike| raw:: latex
+
+   \sout{
+
+.. closed bracket
+.. ===
+
+.. || raw:: latex
+
+   }
+
+
+.. example block
+.. ===
+
+.. |example| raw:: latex
+
+   \begin{exampleblock}{
+
+
+.. |end_example| raw:: latex
+
+   \end{exampleblock}
+
+
+
+.. alert block
+.. ===
+
+.. |alert| raw:: latex
+
+   \begin{alertblock}{
+
+
+.. |end_alert| raw:: latex
+
+   \end{alertblock}
+
+
+
+.. columns
+.. ===
+
+.. |column1| raw:: latex
+
+   \begin{columns}
+  \begin{column}{0.45\textwidth}
+
+.. |column2| raw:: latex
+
+  \end{column}
+  \begin{column}{0.45\textwidth}
+
+
+.. |end_columns| raw:: latex
+
+  \end{column}
+   \end{columns}
+
+
+
+.. |snake| image:: ../../img/py-web-new.png
+   :scale: 15%
+   
+
+
+.. nested blocks
+.. ===
+
+.. |nested| raw:: latex
+
+   \begin{columns}
+  \begin{column}{0.85\textwidth}
+
+.. |end_nested| raw:: latex
+
+  \end{column}
+   \end{columns}
diff --git a/talk/fosdem2015/stylesheet.latex b/talk/fosdem2015/stylesheet.latex
new file mode 100644
--- /dev/null
+++ b/talk/fosdem2015/stylesheet.latex
@@ -0,0 +1,9 @@
+\setbeamercovered{transparent}
+\setbeamertemplate{navigation symbols}{}
+
+\definecolor{darkgreen}{rgb}{0, 0.5, 0.0}
+\newcommand{\docutilsrolegreen}[1]{\color{darkgreen}#1\normalcolor}
+\newcommand{\docutilsrolered}[1]{\color{red}#1\normalcolor}
+
+\newcommand{\green}[1]{\color{darkgreen}#1\normalcolor}
+\newcommand{\red}[1]{\color{red}#1\normalcolor}
diff --git a/talk/fosdem2015/talk.pdf b/talk/fosdem2015/talk.pdf
new file mode 100644
index 
..d82c099a9e525d280f1eb9a6182730411a0a206d
GIT binary patch

[cut]

diff --git a/talk/fosdem2015/talk.rst b/talk/fosdem2015/talk.rst
new file mode 100644
--- /dev/null
+++ b/talk/fosdem2015/talk.rst
@@ -0,0 +1,119 @@
+.. include:: beamerdefs.txt
+
+===
+PyPy and the future of the Python ecosystem
+===
+
+Intro
+-
+
+* @rguillebert
+
+* PyPy contributor for 4 years
+
+* Library compatibility is one of my main interests
+
+  - Cython backend for PyPy
+
+  - NumPyPy
+
+  - PyMetabiosis
+
+* Hire me
+
+* How can we get better implementations ?
+
+* Without throwing away our language features and libraries
+
+Current situation (1/3)
+---
+
+* CPython is by far the most popular implementations
+
+- Poor performance
+
+- No way to use multiple cores in a single process
+
+* PyPy has a fairly small marketshare
+
+- Better performance
+
+- PyPy-STM is a work in progress
+
+* According to PyPI stats, other implementations are virtually unused
+
+Current situation (2

[pypy-commit] extradoc extradoc: More stuff

2015-01-29 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5493:6304fdfd89fb
Date: 2015-01-30 01:51 +0100
http://bitbucket.org/pypy/extradoc/changeset/6304fdfd89fb/

Log:More stuff

diff --git a/talk/fosdem2015/talk.pdf b/talk/fosdem2015/talk.pdf
index 
d82c099a9e525d280f1eb9a6182730411a0a206d..d6bd101dba4bda4ec0c1ac9ea2c519ecd0b8d916
GIT binary patch

[cut]

diff --git a/talk/fosdem2015/talk.rst b/talk/fosdem2015/talk.rst
--- a/talk/fosdem2015/talk.rst
+++ b/talk/fosdem2015/talk.rst
@@ -49,7 +49,7 @@
 
 * Javascript is pretty fast
 
-* PHP is fast...
+* Even PHP is fast these days...
 
 Current situation (3/3)
 ---
@@ -82,6 +82,10 @@
 C APIs in other languages
 -
 
+* JNI / V8
+
+* Lua / Julia
+
 Can we implement a similar API ?
 
 
@@ -89,29 +93,58 @@
 
 * Not that many changes to the C API are required
 
-* It's even possible to do it in pure Python with CFFI
+* It's even possible to have a C API written in pure Python with CFFI
 
 * Designing it to make everyone happy is harder than to actually implement it
 
 * Making people port their extensions is hard
 
-* CPython would need to keep both APIs implement, at least for a while
+* CPython would need to keep both APIs, at least for a while
 
 Where does PyPy fit in this ?
 -
 
 * The most flexible implementation
 
-* Already fast
+* RPython
 
-* Can already interact with C code easily
+The Jit
+---
 
-* PyPy-STM
+* speed.pypy.org
 
-What about short term ?

+* 6.9 times faster than CPython on our benchmarks
 
-* PyMetabiosis
+* Competes with other fast dynamic languages
+
+CFFI
+
+
+* Interacting with C code is very important to the Python community
+
+* CFFI allows you to call C code and expose Python functions to C
+
+* Very fast on PyPy
+
+* As powerful as the C API
+
+STM
+---
+
+* Removing the GIL
+
+* Without having to deal with threads and locks
+
+* Still allows you to share memory between threads
+
+Short term C extension support
+--
+
+* We can bridge PyPy and CPython and let CPython deal with C extensions
+
+* PyMetabiosis demo
+
+* This will allow us to bring the entire scientific stack in a very short 
amount of time
 
 Thank you
 -
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy object-dtype: Add missing space

2015-01-28 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: object-dtype
Changeset: r75558:eaa0525725fa
Date: 2015-01-28 15:30 +0100
http://bitbucket.org/pypy/pypy/changeset/eaa0525725fa/

Log:Add missing space

diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py
--- a/pypy/module/micronumpy/boxes.py
+++ b/pypy/module/micronumpy/boxes.py
@@ -326,7 +326,7 @@
 if not space.is_none(w_out):
 raise OperationError(space.w_NotImplementedError, space.wrap(
 out not supported))
-return self.get_dtype(space).itemtype.round(self, decimals)
+return self.get_dtype(space).itemtype.round(space, self, decimals)
 
 def descr_astype(self, space, w_dtype):
 from pypy.module.micronumpy.descriptor import W_Dtype
diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -684,7 +684,7 @@
 while not arr_iter.done(arr_state):
 round_driver.jit_merge_point(shapelen=shapelen, dtype=dtype)
 w_v = arr_iter.getitem(arr_state).convert_to(space, dtype)
-w_v = dtype.itemtype.round(w_v, decimals)
+w_v = dtype.itemtype.round(space, w_v, decimals)
 out_iter.setitem(out_state, w_v)
 arr_state = arr_iter.next(arr_state)
 out_state = out_iter.next(out_state)
diff --git a/pypy/module/micronumpy/ndarray.py 
b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -113,7 +113,7 @@
 if arr.get_size()  self.get_size():
 raise OperationError(space.w_ValueError, space.wrap(
 index out of range for array))
-size = loop.count_all_true(arr)
+size = loop.count_all_true(space, arr)
 if arr.ndims() == 1:
 res_shape = [size] + self.get_shape()[1:]
 else:
@@ -129,7 +129,7 @@
 if idx.get_size()  self.get_size():
 raise OperationError(space.w_ValueError, space.wrap(
 index out of range for array))
-size = loop.count_all_true(idx)
+size = loop.count_all_true(space, idx)
 if size  val.get_size() and val.get_size() != 1:
 raise oefmt(space.w_ValueError,
 NumPy boolean array indexing assignment 
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -397,7 +397,7 @@
 return 0
 
 @specialize.argtype(1)
-def round(self, v, decimals=0):
+def round(self, space, v, decimals=0):
 if decimals != 0:
 return v
 return Float64().box(self.unbox(v))
@@ -525,7 +525,7 @@
 return self.box(ans)
 
 @specialize.argtype(1)
-def round(self, v, decimals=0):
+def round(self, space, v, decimals=0):
 raw = self.for_computation(self.unbox(v))
 if decimals  0:
 # No ** in rpython
@@ -752,7 +752,7 @@
 return math.ceil(v)
 
 @specialize.argtype(1)
-def round(self, v, decimals=0):
+def round(self, space, v, decimals=0):
 raw = self.for_computation(self.unbox(v))
 if rfloat.isinf(raw):
 return v
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy object-dtype: Now that object arrays work, raise the proper exception

2015-01-28 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: object-dtype
Changeset: r75565:7f1fc67f7b45
Date: 2015-01-28 16:55 +0100
http://bitbucket.org/pypy/pypy/changeset/7f1fc67f7b45/

Log:Now that object arrays work, raise the proper exception

diff --git a/pypy/module/micronumpy/ndarray.py 
b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -157,6 +157,8 @@
 if (isinstance(w_item, W_NDimArray) or
 space.isinstance_w(w_item, space.w_list)):
 w_item = convert_to_array(space, w_item)
+if w_item.implementation.dtype.num == NPY.OBJECT:
+raise OperationError(space.w_TypeError, space.wrap(long() 
argument must be a string or a number, not 'object')) # Mimic numpy's error 
message
 if shape is None:
 shape = w_item.get_shape()
 else:
diff --git a/pypy/module/micronumpy/test/test_ndarray.py 
b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -3135,11 +3135,7 @@
 assert b[35] == 200
 b[[slice(25, 30)]] = range(5)
 assert all(a[:5] == range(5))
-import sys
-if '__pypy__' not in sys.builtin_module_names:
-raises(TypeError, 'b[[[slice(25, 125)]]]')
-else:
-raises(NotImplementedError, 'b[[[slice(25, 125)]]]')
+raises(TypeError, 'b[[[slice(25, 125)]]]')
 
 def test_cumsum(self):
 from numpy import arange
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy object-dtype: Don't inherit Primitive

2015-01-28 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: object-dtype
Changeset: r75566:155d70548c64
Date: 2015-01-28 17:25 +0100
http://bitbucket.org/pypy/pypy/changeset/155d70548c64/

Log:Don't inherit Primitive

diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -1625,7 +1625,7 @@
 
 _all_objs_for_tests = [] # for tests
 
-class ObjectType(Primitive, BaseType):
+class ObjectType(BaseType):
 T = lltype.Signed
 BoxType = boxes.W_ObjectBox
 
@@ -1660,6 +1660,11 @@
 w_obj = _all_objs_for_tests[res]
 return w_obj
 
+def fill(self, storage, width, box, start, stop, offset):
+value = self.unbox(box)
+for i in xrange(start, stop, width):
+self._write(storage, i, offset, value)
+
 def unbox(self, box):
 assert isinstance(box, self.BoxType)
 return box.w_obj
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy object-dtype: Object ndarrays are now initialized with Nones

2015-01-26 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: object-dtype
Changeset: r75536:dca1f6200f69
Date: 2015-01-26 15:19 +0100
http://bitbucket.org/pypy/pypy/changeset/dca1f6200f69/

Log:Object ndarrays are now initialized with Nones

diff --git a/pypy/module/micronumpy/base.py b/pypy/module/micronumpy/base.py
--- a/pypy/module/micronumpy/base.py
+++ b/pypy/module/micronumpy/base.py
@@ -34,11 +34,13 @@
 
 @staticmethod
 def from_shape(space, shape, dtype, order='C', w_instance=None, zero=True):
-from pypy.module.micronumpy import concrete
+from pypy.module.micronumpy import concrete, descriptor, boxes
 from pypy.module.micronumpy.strides import calc_strides
 strides, backstrides = calc_strides(shape, dtype.base, order)
 impl = concrete.ConcreteArray(shape, dtype.base, order, strides,
   backstrides, zero=zero)
+if dtype == descriptor.get_dtype_cache(space).w_objectdtype:
+impl.fill(space, boxes.W_ObjectBox(space.w_None))
 if w_instance:
 return wrap_impl(space, space.type(w_instance), w_instance, impl)
 return W_NDimArray(impl)
diff --git a/pypy/module/micronumpy/descriptor.py 
b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -586,8 +586,7 @@
 if w_dtype is dtype.w_box_type:
 return dtype
 if space.isinstance_w(w_dtype, space.w_type):
-raise oefmt(space.w_NotImplementedError,
-cannot create dtype with type '%N', w_dtype)
+return cache.w_objectdtype
 raise oefmt(space.w_TypeError, data type not understood)
 
 
diff --git a/pypy/module/micronumpy/test/test_dtypes.py 
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -1345,9 +1345,12 @@
 import sys
 class Polynomial(object):
 pass
-if '__pypy__' in sys.builtin_module_names:
-exc = raises(NotImplementedError, array, Polynomial())
-assert exc.value.message.find('unable to create dtype from 
objects') = 0
-else:
-a = array(Polynomial())
-assert a.shape == ()
+a = array(Polynomial())
+assert a.shape == ()
+
+def test_uninitialized_object_array_is_filled_by_None(self):
+import numpy as np
+
+a = np.ndarray([5], dtype=O)
+
+assert a[0] == None
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -1624,7 +1624,7 @@
 
 _all_objs_for_tests = [] # for tests
 
-class ObjectType(BaseType):
+class ObjectType(Primitive, BaseType):
 T = lltype.Signed
 BoxType = boxes.W_ObjectBox
 
@@ -1669,6 +1669,10 @@
 def str_format(self, space, box):
 return space.str_w(space.repr(self.unbox(box)))
 
+@staticmethod
+def for_computation(v):
+return v
+
 class FlexibleType(BaseType):
 def get_element_size(self):
 return rffi.sizeof(self.T)
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -608,6 +608,7 @@
 uint64_dtype = descriptor.get_dtype_cache(space).w_uint64dtype
 complex_dtype = descriptor.get_dtype_cache(space).w_complex128dtype
 float_dtype = descriptor.get_dtype_cache(space).w_float64dtype
+object_dtype = descriptor.get_dtype_cache(space).w_objectdtype
 if isinstance(w_obj, boxes.W_GenericBox):
 dtype = w_obj.get_dtype(space)
 return find_binop_result_dtype(space, dtype, current_guess)
@@ -638,9 +639,10 @@
 return descriptor.variable_dtype(space,
'S%d' % space.len_w(w_obj))
 return current_guess
-raise oefmt(space.w_NotImplementedError,
-'unable to create dtype from objects, %T instance not '
-'supported', w_obj)
+return object_dtype
+#raise oefmt(space.w_NotImplementedError,
+#'unable to create dtype from objects, %T instance not '
+#'supported', w_obj)
 
 
 def ufunc_dtype_caller(space, ufunc_name, op_name, argcount, comparison_func,
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy object-dtype: Test for adding 2 object arrays

2015-01-26 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: object-dtype
Changeset: r75537:70ad29712173
Date: 2015-01-26 16:01 +0100
http://bitbucket.org/pypy/pypy/changeset/70ad29712173/

Log:Test for adding 2 object arrays

diff --git a/pypy/module/micronumpy/test/test_dtypes.py 
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -1354,3 +1354,12 @@
 a = np.ndarray([5], dtype=O)
 
 assert a[0] == None
+
+def test_object_arrays_add(self):
+import numpy as np
+
+a = np.array([foo], dtype=object)
+b = np.array([bar], dtype=object)
+
+res = a + b
+assert res[0] == foobar
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy object-dtype: space has to be passed to a lot of places now, this breaks everything

2015-01-26 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: object-dtype
Changeset: r75538:79a2270b06a2
Date: 2015-01-26 17:11 +0100
http://bitbucket.org/pypy/pypy/changeset/79a2270b06a2/

Log:space has to be passed to a lot of places now, this breaks
everything

diff --git a/pypy/module/micronumpy/arrayops.py 
b/pypy/module/micronumpy/arrayops.py
--- a/pypy/module/micronumpy/arrayops.py
+++ b/pypy/module/micronumpy/arrayops.py
@@ -83,7 +83,7 @@
 x = convert_to_array(space, w_x)
 y = convert_to_array(space, w_y)
 if x.is_scalar() and y.is_scalar() and arr.is_scalar():
-if arr.get_dtype().itemtype.bool(arr.get_scalar_value()):
+if arr.get_dtype().itemtype.bool(space, arr.get_scalar_value()):
 return x
 return y
 dtype = ufuncs.find_binop_result_dtype(space, x.get_dtype(),
diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py
--- a/pypy/module/micronumpy/boxes.py
+++ b/pypy/module/micronumpy/boxes.py
@@ -228,7 +228,7 @@
 return space.hex(self.descr_int(space))
 
 def descr_nonzero(self, space):
-return space.wrap(self.get_dtype(space).itemtype.bool(self))
+return space.wrap(self.get_dtype(space).itemtype.bool(space, self))
 
 def _unaryop_impl(ufunc_name):
 def impl(self, space, w_out=None):
@@ -412,10 +412,10 @@
 return space.call_args(w_meth, __args__)
 
 def descr_get_real(self, space):
-return self.get_dtype(space).itemtype.real(self)
+return self.get_dtype(space).itemtype.real(space, self)
 
 def descr_get_imag(self, space):
-return self.get_dtype(space).itemtype.imag(self)
+return self.get_dtype(space).itemtype.imag(space, self)
 
 w_flags = None
 
diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -72,7 +72,7 @@
 if right_iter:
 w_right = right_iter.getitem(right_state).convert_to(space, 
calc_dtype)
 right_state = right_iter.next(right_state)
-out_iter.setitem(out_state, func(calc_dtype, w_left, 
w_right).convert_to(
+out_iter.setitem(out_state, func(space, calc_dtype, w_left, 
w_right).convert_to(
 space, res_dtype))
 out_state = out_iter.next(out_state)
 return out
@@ -94,7 +94,7 @@
 call1_driver.jit_merge_point(shapelen=shapelen, func=func,
  calc_dtype=calc_dtype, 
res_dtype=res_dtype)
 elem = obj_iter.getitem(obj_state).convert_to(space, calc_dtype)
-out_iter.setitem(out_state, func(calc_dtype, elem).convert_to(space, 
res_dtype))
+out_iter.setitem(out_state, func(space, calc_dtype, 
elem).convert_to(space, res_dtype))
 out_state = out_iter.next(out_state)
 obj_state = obj_iter.next(obj_state)
 return out
@@ -153,9 +153,9 @@
   done_func=done_func,
   calc_dtype=calc_dtype)
 rval = obj_iter.getitem(obj_state).convert_to(space, calc_dtype)
-if done_func is not None and done_func(calc_dtype, rval):
+if done_func is not None and done_func(space, calc_dtype, rval):
 return rval
-cur_value = func(calc_dtype, cur_value, rval)
+cur_value = func(space, calc_dtype, cur_value, rval)
 obj_state = obj_iter.next(obj_state)
 return cur_value
 
@@ -179,7 +179,7 @@
 reduce_cum_driver.jit_merge_point(shapelen=shapelen, func=func,
   dtype=calc_dtype)
 rval = obj_iter.getitem(obj_state).convert_to(space, calc_dtype)
-cur_value = func(calc_dtype, cur_value, rval)
+cur_value = func(space, calc_dtype, cur_value, rval)
 out_iter.setitem(out_state, cur_value)
 out_state = out_iter.next(out_state)
 obj_state = obj_iter.next(obj_state)
@@ -222,7 +222,7 @@
 where_driver.jit_merge_point(shapelen=shapelen, dtype=dtype,
 arr_dtype=arr_dtype)
 w_cond = arr_iter.getitem(arr_state)
-if arr_dtype.itemtype.bool(w_cond):
+if arr_dtype.itemtype.bool(space, w_cond):
 w_val = x_iter.getitem(x_state).convert_to(space, dtype)
 else:
 w_val = y_iter.getitem(y_state).convert_to(space, dtype)
@@ -354,7 +354,7 @@
 dot_driver.jit_merge_point(dtype=dtype)
 lval = left_impl.getitem(i1).convert_to(space, dtype)
 rval = right_impl.getitem(i2).convert_to(space, dtype)
-oval = dtype.itemtype.add(oval, dtype.itemtype.mul(lval, rval))
+oval = dtype.itemtype.add(space, oval, 
dtype.itemtype.mul(space, lval, rval))
 i1 += s1
 i2 += s2
 outi.setitem(outs, oval)
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- 

[pypy-commit] pypy object-dtype: Add space everywhere

2015-01-26 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: object-dtype
Changeset: r75540:7cbb4af9b24f
Date: 2015-01-26 17:56 +0100
http://bitbucket.org/pypy/pypy/changeset/7cbb4af9b24f/

Log:Add space everywhere

diff --git a/pypy/module/micronumpy/arrayops.py 
b/pypy/module/micronumpy/arrayops.py
--- a/pypy/module/micronumpy/arrayops.py
+++ b/pypy/module/micronumpy/arrayops.py
@@ -192,7 +192,7 @@
 
 
 def count_nonzero(space, w_obj):
-return space.wrap(loop.count_all_true(convert_to_array(space, w_obj)))
+return space.wrap(loop.count_all_true(space, convert_to_array(space, 
w_obj)))
 
 
 def choose(space, w_arr, w_choices, w_out, w_mode):
diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -268,10 +268,10 @@
 out_indices = out_iter.indices(out_state)
 if out_indices[axis] == 0:
 if identity is not None:
-w_val = func(dtype, identity, w_val)
+w_val = func(space, dtype, identity, w_val)
 else:
 cur = temp_iter.getitem(temp_state)
-w_val = func(dtype, cur, w_val)
+w_val = func(space, dtype, cur, w_val)
 
 out_iter.setitem(out_state, w_val)
 out_state = out_iter.next(out_state)
@@ -288,7 +288,7 @@
greens = ['shapelen', 'dtype'],
reds = 'auto')
 
-def argmin_argmax(arr):
+def argmin_argmax(space, arr):
 result = 0
 idx = 1
 dtype = arr.get_dtype()
@@ -299,8 +299,8 @@
 while not iter.done(state):
 arg_driver.jit_merge_point(shapelen=shapelen, dtype=dtype)
 w_val = iter.getitem(state)
-new_best = getattr(dtype.itemtype, op_name)(cur_best, w_val)
-if dtype.itemtype.ne(new_best, cur_best):
+new_best = getattr(dtype.itemtype, op_name)(space, cur_best, w_val)
+if dtype.itemtype.ne(space, new_best, cur_best):
 result = idx
 cur_best = new_best
 state = iter.next(state)
@@ -379,9 +379,9 @@
 state = iter.next(state)
 return s
 
-def count_all_true(arr):
+def count_all_true(space, arr):
 if arr.is_scalar():
-return arr.get_dtype().itemtype.bool(arr.get_scalar_value())
+return arr.get_dtype().itemtype.bool(space, arr.get_scalar_value())
 else:
 return count_all_true_concrete(arr.implementation)
 
@@ -662,12 +662,12 @@
 arr_state = arr_iter.next(arr_state)
 if min_iter is not None:
 w_min = min_iter.getitem(min_state).convert_to(space, dtype)
-if dtype.itemtype.lt(w_v, w_min):
+if dtype.itemtype.lt(space, w_v, w_min):
 w_v = w_min
 min_state = min_iter.next(min_state)
 if max_iter is not None:
 w_max = max_iter.getitem(max_state).convert_to(space, dtype)
-if dtype.itemtype.gt(w_v, w_max):
+if dtype.itemtype.gt(space, w_v, w_max):
 w_v = w_max
 max_state = max_iter.next(max_state)
 out_iter.setitem(out_state, w_v)
@@ -750,7 +750,7 @@
 last_key_val = key_iter.getitem(key_state)
 while not key_iter.done(key_state):
 key_val = key_iter.getitem(key_state)
-if dtype.itemtype.lt(last_key_val, key_val):
+if dtype.itemtype.lt(space, last_key_val, key_val):
 max_idx = size
 else:
 min_idx = 0
@@ -760,7 +760,7 @@
 binsearch_driver.jit_merge_point(dtype=dtype)
 mid_idx = min_idx + ((max_idx - min_idx)  1)
 mid_val = arr.getitem(space, [mid_idx]).convert_to(space, 
dtype)
-if op(mid_val, key_val):
+if op(space, mid_val, key_val):
 min_idx = mid_idx + 1
 else:
 max_idx = mid_idx
diff --git a/pypy/module/micronumpy/ndarray.py 
b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -1068,7 +1068,7 @@
 raise oefmt(space.w_NotImplementedError,
 '%s not implemented for %s',
 op_name, self.get_dtype().get_name())
-return space.wrap(getattr(loop, op_name)(self))
+return space.wrap(getattr(loop, op_name)(space, self))
 return func_with_new_name(impl, reduce_%s_impl % op_name)
 
 descr_argmax = _reduce_argmax_argmin_impl(max)
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -44,10 +44,10 @@
 def complex_unary_op(func):
 specialize.argtype(1)(func)
 @functools.wraps(func)
-def dispatcher(self, v):
+def dispatcher(self, space, v):
 return self.box_complex(
 *func(
- 

[pypy-commit] pypy object-dtype: Fix Object dtype str representation

2015-01-16 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: object-dtype
Changeset: r75386:e7c050377daf
Date: 2015-01-16 15:31 +0100
http://bitbucket.org/pypy/pypy/changeset/e7c050377daf/

Log:Fix Object dtype str representation

diff --git a/pypy/module/micronumpy/descriptor.py 
b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -54,7 +54,7 @@
 self.char = char
 self.w_box_type = w_box_type
 if byteorder is None:
-if itemtype.get_element_size() == 1:
+if itemtype.get_element_size() == 1 or isinstance(itemtype, 
types.ObjectType):
 byteorder = NPY.IGNORE
 else:
 byteorder = NPY.NATIVE
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy object-dtype: Pass space around

2015-01-16 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: object-dtype
Changeset: r75387:3126fa1b95b9
Date: 2015-01-16 15:54 +0100
http://bitbucket.org/pypy/pypy/changeset/3126fa1b95b9/

Log:Pass space around

diff --git a/pypy/module/micronumpy/ndarray.py 
b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -254,16 +254,16 @@
 def descr_repr(self, space):
 cache = get_appbridge_cache(space)
 if cache.w_array_repr is None:
-return space.wrap(self.dump_data())
+return space.wrap(self.dump_data(space))
 return space.call_function(cache.w_array_repr, self)
 
 def descr_str(self, space):
 cache = get_appbridge_cache(space)
 if cache.w_array_str is None:
-return space.wrap(self.dump_data(prefix='', separator='', 
suffix=''))
+return space.wrap(self.dump_data(space, prefix='', separator='', 
suffix=''))
 return space.call_function(cache.w_array_str, self)
 
-def dump_data(self, prefix='array(', separator=',', suffix=')'):
+def dump_data(self, space, prefix='array(', separator=',', suffix=')'):
 i, state = self.create_iter()
 first = True
 dtype = self.get_dtype()
@@ -280,7 +280,7 @@
 if self.is_scalar() and dtype.is_str():
 s.append(dtype.itemtype.to_str(i.getitem(state)))
 else:
-s.append(dtype.itemtype.str_format(i.getitem(state)))
+s.append(dtype.itemtype.str_format(space, i.getitem(state)))
 state = i.next(state)
 if not self.is_scalar():
 s.append(']')
@@ -1189,7 +1189,7 @@
 improper dtype '%R', dtype)
 self.implementation = W_NDimArray.from_shape_and_storage(
 space, [space.int_w(i) for i in space.listview(shape)],
-rffi.str2charp(space.str_w(storage), track_allocation=False), 
+rffi.str2charp(space.str_w(storage), track_allocation=False),
 dtype, storage_bytes=space.len_w(storage), 
owning=True).implementation
 
 def descr___array_finalize__(self, space, w_obj):
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -1871,7 +1871,7 @@
 def str_format(self, space, box):
 assert isinstance(box, boxes.W_VoidBox)
 arr = self.readarray(box.arr, box.ofs, 0, box.dtype)
-return arr.dump_data(prefix='', suffix='')
+return arr.dump_data(space, prefix='', suffix='')
 
 def to_builtin_type(self, space, item):
 ''' From the documentation of ndarray.item():
@@ -1980,7 +1980,7 @@
 else:
 pieces.append(, )
 val = tp.read(box.arr, box.ofs, ofs, subdtype)
-pieces.append(tp.str_format(val))
+pieces.append(tp.str_format(space, val))
 pieces.append())
 return .join(pieces)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy object-dtype: Add w_object to FakeSpace

2015-01-15 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: object-dtype
Changeset: r75352:d02fe29f5e55
Date: 2015-01-15 16:08 +0100
http://bitbucket.org/pypy/pypy/changeset/d02fe29f5e55/

Log:Add w_object to FakeSpace

diff --git a/pypy/module/micronumpy/compile.py 
b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -67,6 +67,7 @@
 w_unicode = W_TypeObject(unicode)
 w_complex = W_TypeObject(complex)
 w_dict = W_TypeObject(dict)
+w_object = W_TypeObject(object)
 
 def __init__(self):
 NOT_RPYTHON
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy object-dtype: Unskip test

2015-01-15 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: object-dtype
Changeset: r75357:d6e6f6529ef3
Date: 2015-01-15 17:09 +0100
http://bitbucket.org/pypy/pypy/changeset/d6e6f6529ef3/

Log:Unskip test

diff --git a/pypy/module/micronumpy/test/test_dtypes.py 
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -472,11 +472,8 @@
 class O(object):
 pass
 for o in [object, O]:
-if '__pypy__' not in sys.builtin_module_names:
-assert np.dtype(o).str == '|O8'
-else:
-exc = raises(NotImplementedError, np.dtype(o))
-assert exc.value[0] == cannot create dtype with type '%s' % 
o.__name__
+print np.dtype(o).byteorder
+assert np.dtype(o).str == '|O8'
 
 class AppTestTypes(BaseAppTestDtypes):
 def test_abstract_types(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Add dlopen flags to verify on pypy

2014-12-17 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r1587:0853a872dedf
Date: 2014-10-21 12:55 +0200
http://bitbucket.org/cffi/cffi/changeset/0853a872dedf/

Log:Add dlopen flags to verify on pypy

diff --git a/cffi/vengine_gen.py b/cffi/vengine_gen.py
--- a/cffi/vengine_gen.py
+++ b/cffi/vengine_gen.py
@@ -58,12 +58,12 @@
 modname = self.verifier.get_module_name()
 prnt(void %s%s(void) { }\n % (prefix, modname))
 
-def load_library(self):
+def load_library(self, flags=0):
 # import it with the CFFI backend
 backend = self.ffi._backend
 # needs to make a path that contains '/', on Posix
 filename = os.path.join(os.curdir, self.verifier.modulefilename)
-module = backend.load_library(filename)
+module = backend.load_library(filename, flags)
 #
 # call loading_gen_struct() to get the struct layout inferred by
 # the C compiler
diff --git a/cffi/verifier.py b/cffi/verifier.py
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -16,7 +16,7 @@
 class Verifier(object):
 
 def __init__(self, ffi, preamble, tmpdir=None, modulename=None,
- ext_package=None, tag='', force_generic_engine=False, **kwds):
+ ext_package=None, tag='', force_generic_engine=False, 
flags=0, **kwds):
 self.ffi = ffi
 self.preamble = preamble
 if not modulename:
@@ -24,6 +24,7 @@
 vengine_class = _locate_engine_class(ffi, force_generic_engine)
 self._vengine = vengine_class(self)
 self._vengine.patch_extension_kwds(kwds)
+self.flags = flags
 self.kwds = kwds
 #
 if modulename:
@@ -158,7 +159,7 @@
 
 def _load_library(self):
 assert self._has_module
-return self._vengine.load_library()
+return self._vengine.load_library(self.flags)
 
 # 
 
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -1962,3 +1962,17 @@
 n = (1  29) + i
 lib.SetLastError(n)
 assert ffi.getwinerror()[0] == n
+
+def test_verify_dlopen_flags():
+ffi1 = FFI()
+ffi2 = FFI()
+
+ffi1.cdef(int foo;)
+ffi2.cdef(int foo;)
+
+lib1 = ffi1.verify(int foo;, modulename=foo1, flags=ffi1.RTLD_GLOBAL)
+lib2 = ffi2.verify(int foo;, modulename=foo2, flags=ffi2.RTLD_GLOBAL)
+
+lib1.foo = 42
+
+assert lib2.foo == 42
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Make sure the flags kwarg of verify has no effect on Windows

2014-12-17 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r1591:b7065ad45a58
Date: 2014-12-17 17:57 +0100
http://bitbucket.org/cffi/cffi/changeset/b7065ad45a58/

Log:Make sure the flags kwarg of verify has no effect on Windows

diff --git a/cffi/vengine_cpy.py b/cffi/vengine_cpy.py
--- a/cffi/vengine_cpy.py
+++ b/cffi/vengine_cpy.py
@@ -141,9 +141,10 @@
 def load_library(self, flags=None):
 # XXX review all usages of 'self' here!
 # import it as a new extension module
-previous_flags = sys.getdlopenflags()
+if hasattr(sys, getdlopenflags):
+previous_flags = sys.getdlopenflags()
 try:
-if flags is not None:
+if hasattr(sys, setdlopenflags) and flags is not None:
 sys.setdlopenflags(flags)
 module = imp.load_dynamic(self.verifier.get_module_name(),
   self.verifier.modulefilename)
@@ -151,7 +152,8 @@
 error = importing %r: %s % (self.verifier.modulefilename, e)
 raise ffiplatform.VerificationError(error)
 finally:
-sys.setdlopenflags(previous_flags)
+if hasattr(sys, setdlopenflags):
+sys.setdlopenflags(previous_flags)
 #
 # call loading_cpy_struct() to get the struct layout inferred by
 # the C compiler
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Import verify dlopen flags for cpython

2014-12-17 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r1588:2ff481ead26d
Date: 2014-10-21 13:28 +0200
http://bitbucket.org/cffi/cffi/changeset/2ff481ead26d/

Log:Import verify dlopen flags for cpython

diff --git a/cffi/vengine_cpy.py b/cffi/vengine_cpy.py
--- a/cffi/vengine_cpy.py
+++ b/cffi/vengine_cpy.py
@@ -138,15 +138,19 @@
 prnt()
 prnt('#endif')
 
-def load_library(self):
+def load_library(self, flags=0):
 # XXX review all usages of 'self' here!
 # import it as a new extension module
+previous_flags = sys.getdlopenflags()
 try:
+sys.setdlopenflags(flags)
 module = imp.load_dynamic(self.verifier.get_module_name(),
   self.verifier.modulefilename)
 except ImportError as e:
 error = importing %r: %s % (self.verifier.modulefilename, e)
 raise ffiplatform.VerificationError(error)
+finally:
+sys.setdlopenflags(previous_flags)
 #
 # call loading_cpy_struct() to get the struct layout inferred by
 # the C compiler
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -1965,14 +1965,18 @@
 
 def test_verify_dlopen_flags():
 ffi1 = FFI()
-ffi2 = FFI()
+ffi1.cdef(int foo;)
 
-ffi1.cdef(int foo;)
-ffi2.cdef(int foo;)
-
-lib1 = ffi1.verify(int foo;, modulename=foo1, flags=ffi1.RTLD_GLOBAL)
-lib2 = ffi2.verify(int foo;, modulename=foo2, flags=ffi2.RTLD_GLOBAL)
+lib1 = ffi1.verify(int foo;, flags=ffi1.RTLD_GLOBAL | ffi1.RTLD_LAZY)
+lib2 = get_second_lib()
 
 lib1.foo = 42
 
 assert lib2.foo == 42
+
+def get_second_lib():
+# Hack, using modulename makes the test fail
+ffi2 = FFI()
+ffi2.cdef(int foo;)
+lib2 = ffi2.verify(int foo;, flags=ffi2.RTLD_GLOBAL | ffi2.RTLD_LAZY)
+return lib2
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Add documentation for the flags argument of verify

2014-12-17 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r1590:36d8fcb90561
Date: 2014-12-17 17:50 +0100
http://bitbucket.org/cffi/cffi/changeset/36d8fcb90561/

Log:Add documentation for the flags argument of verify

diff --git a/doc/source/index.rst b/doc/source/index.rst
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -500,7 +500,7 @@
 The verification step
 -
 
-``ffi.verify(source, tmpdir=.., ext_package=.., modulename=.., **kwargs)``:
+``ffi.verify(source, tmpdir=.., ext_package=.., modulename=.., flags=.., 
**kwargs)``:
 verifies that the current ffi signatures
 compile on this machine, and return a dynamic library object.  The
 dynamic library can be used to call functions and access global
@@ -667,6 +667,10 @@
check.  Be sure to have other means of clearing the ``tmpdir``
whenever you change your sources.
 
+.. versionadded:: 0.9
+   The optional ``flags`` argument has been added, see ``man dlopen`` (ignored
+   on Windows).  It defaults to ``ffi.RTLD_NOW``.
+
 This function returns a library object that gets closed when it goes
 out of scope.  Make sure you keep the library object around as long as
 needed.
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Merge heads

2014-12-17 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r1592:9267d5f13672
Date: 2014-12-17 18:04 +0100
http://bitbucket.org/cffi/cffi/changeset/9267d5f13672/

Log:Merge heads

diff --git a/TODO b/TODO
--- a/TODO
+++ b/TODO
@@ -1,10 +1,3 @@
 
 
-Next steps
---
-
-verify() handles typedef ... some_integer_type, but this creates
-an opaque type that works like a struct (so we can't get the value
-out of it).
-
-accept and kill static inline in the cdefs
+Add other required types from stdint.h
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -4765,7 +4765,7 @@
 CFieldObject *cf;
 Py_ssize_t offset;
 
-if (!PyArg_ParseTuple(args, O!O:typeof,
+if (!PyArg_ParseTuple(args, O!O:typeoffsetof,
   CTypeDescr_Type, ct, fieldname))
 return NULL;
 
diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -208,6 +208,8 @@
 
 def _add_constants(self, key, val):
 if key in self._int_constants:
+if self._int_constants[key] == val:
+return # ignore identical double declarations
 raise api.FFIError(
 multiple declarations of constant: %s % (key,))
 self._int_constants[key] = val
diff --git a/cffi/vengine_cpy.py b/cffi/vengine_cpy.py
--- a/cffi/vengine_cpy.py
+++ b/cffi/vengine_cpy.py
@@ -235,7 +235,8 @@
 converter = '_cffi_to_c_int'
 extraarg = ', %s' % tp.name
 else:
-converter = '_cffi_to_c_%s' % (tp.name.replace(' ', '_'),)
+converter = '(%s)_cffi_to_c_%s' % (tp.get_c_name(''),
+   tp.name.replace(' ', '_'))
 errvalue = '-1'
 #
 elif isinstance(tp, model.PointerType):
@@ -274,8 +275,8 @@
 self._prnt('  if (datasize != 0) {')
 self._prnt('if (datasize  0)')
 self._prnt('  %s;' % errcode)
-self._prnt('%s = alloca(datasize);' % (tovar,))
-self._prnt('memset((void *)%s, 0, datasize);' % (tovar,))
+self._prnt('%s = alloca((size_t)datasize);' % (tovar,))
+self._prnt('memset((void *)%s, 0, (size_t)datasize);' % (tovar,))
 self._prnt('if (_cffi_convert_array_from_object('
'(char *)%s, _cffi_type(%d), %s)  0)' % (
 tovar, self._gettypenum(tp), fromvar))
@@ -835,12 +836,15 @@
 PyLong_FromLongLong((long long)(x)))
 
 #define _cffi_from_c_int(x, type)\
-(((type)-1)  0 ?   /* unsigned */   \
-(sizeof(type)  sizeof(long) ? PyInt_FromLong(x) :   \
- sizeof(type) == sizeof(long) ? PyLong_FromUnsignedLong(x) : \
-PyLong_FromUnsignedLongLong(x))  \
-  : (sizeof(type) = sizeof(long) ? PyInt_FromLong(x) :  \
-PyLong_FromLongLong(x)))
+(((type)-1)  0 ? /* unsigned */ \
+(sizeof(type)  sizeof(long) ?   \
+PyInt_FromLong((long)x) :\
+ sizeof(type) == sizeof(long) ?  \
+PyLong_FromUnsignedLong((unsigned long)x) :  \
+PyLong_FromUnsignedLongLong((unsigned long long)x)) :\
+(sizeof(type) = sizeof(long) ?  \
+PyInt_FromLong((long)x) :\
+PyLong_FromLongLong((long long)x)))
 
 #define _cffi_to_c_int(o, type)  \
 (sizeof(type) == 1 ? (((type)-1)  0 ? (type)_cffi_to_c_u8(o)\
@@ -851,7 +855,7 @@
  : (type)_cffi_to_c_i32(o)) :\
  sizeof(type) == 8 ? (((type)-1)  0 ? (type)_cffi_to_c_u64(o)   \
  : (type)_cffi_to_c_i64(o)) :\
- (Py_FatalError(unsupported size for type  #type), 0))
+ (Py_FatalError(unsupported size for type  #type), (type)0))
 
 #define _cffi_to_c_i8\
  ((int(*)(PyObject *))_cffi_exports[1])
diff --git a/cffi/verifier.py b/cffi/verifier.py
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -16,7 +16,8 @@
 class Verifier(object):
 
 def __init__(self, ffi, preamble, tmpdir=None, modulename=None,
- ext_package=None, tag='', force_generic_engine=False, 
flags=None, **kwds):
+ ext_package=None, tag='', force_generic_engine=False,
+ source_extension='.c', flags=None, **kwds):
 self.ffi = ffi
 self.preamble = preamble
 if not modulename:
@@ -44,7 +45,7 @@
   k1, k2)
 suffix 

[pypy-commit] extradoc extradoc: Nearly done ?

2014-12-06 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5481:89e8eadeff5e
Date: 2014-12-06 14:02 +0530
http://bitbucket.org/pypy/extradoc/changeset/89e8eadeff5e/

Log:Nearly done ?

diff --git a/talk/scipyindia2014/talk.pdf b/talk/scipyindia2014/talk.pdf
new file mode 100644
index 
..4be849fc047dc21919a478732a2521894f5b01fc
GIT binary patch

[cut]

diff --git a/talk/scipyindia2014/talk.rst b/talk/scipyindia2014/talk.rst
--- a/talk/scipyindia2014/talk.rst
+++ b/talk/scipyindia2014/talk.rst
@@ -107,14 +107,14 @@
 
 * Most of numpy is there
 
-* XXX is missing
+* linalg and the object dtype are the two biggest features that we haven't 
implemented yet
 
 NumPyPy performance
 ---
 
 * Vectorized operations should be as fast as Numpy
 
-* Using ndarrays as you would use arrays in C or Java should be as fast
+* Using ndarrays as you would use arrays in C or Java should be as fast as the 
vectorized way
 
 * Lazy evaluation ?
 
@@ -123,7 +123,7 @@
 
 * Work in progress
 
-* Allows you to use any CPython module on PyPy
+* Allows you to use any CPython module on PyPy (scipy for example)
 
 * Embeds CPython into PyPy with CFFI
 
@@ -164,7 +164,7 @@
 
 * Provides a decorator that allows you to run specific functions on PyPy
 
-* Is used the same way as numba, but different performance caracteristics
+* Is used the same way as numba, but different performance characteristics
 
 JitPy
 -
@@ -188,6 +188,17 @@
 
 |end_scriptsize|
 
+Future
+--
+
+* Full numpy support
+
+* Improved C extension compatibility
+
+* I would like to see Cython work with PyPy
+
+* No more Global Interpreter Lock
+
 Thank You
 -
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Progress

2014-12-05 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5478:dd38c1bea82c
Date: 2014-12-06 03:31 +0530
http://bitbucket.org/pypy/extradoc/changeset/dd38c1bea82c/

Log:Progress

diff --git a/talk/scipyindia2014/talk.rst b/talk/scipyindia2014/talk.rst
--- a/talk/scipyindia2014/talk.rst
+++ b/talk/scipyindia2014/talk.rst
@@ -1,3 +1,5 @@
+.. include:: beamerdefs.txt
+
 =
 PyPy and the scientific stack
 =
@@ -40,7 +42,16 @@
 Speed
 -
 
-* XXX : Insert speed.pypy.org screenshot
+.. image:: speed.png
+   :scale: 50%
+   :align: center
+
+How ?
+-
+
+* Tracing Just-In-Time compiler
+
+* Removes overhead
 
 Demo
 
@@ -103,8 +114,23 @@
 NumPyPy performance
 ---
 
+* Vectorized operations should be as fast as Numpy
+
+* Using ndarrays as you would use arrays in C or Java should be as fast
+
+* Lazy evaluation ?
+
 PyMetabiosis
 
 
+* Work in progress
+
 JitPy
 -
+
+* Work in progress
+
+Thank You
+-
+
+Questions ?
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add image

2014-12-05 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5479:9883ef8b82cc
Date: 2014-12-06 03:47 +0530
http://bitbucket.org/pypy/extradoc/changeset/9883ef8b82cc/

Log:Add image

diff --git a/talk/scipyindia2014/speed.png b/talk/scipyindia2014/speed.png
new file mode 100644
index 
..63b771ce59358bbcb28efbba84a43f03328b4554
GIT binary patch

[cut]

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Progress

2014-12-05 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5480:61ba4f722878
Date: 2014-12-06 11:25 +0530
http://bitbucket.org/pypy/extradoc/changeset/61ba4f722878/

Log:Progress

diff --git a/talk/scipyindia2014/talk.rst b/talk/scipyindia2014/talk.rst
--- a/talk/scipyindia2014/talk.rst
+++ b/talk/scipyindia2014/talk.rst
@@ -17,8 +17,6 @@
 
 * Software consultant
 
-* Feel free to interrupt me
-
 PyPy
 
 
@@ -125,11 +123,71 @@
 
 * Work in progress
 
+* Allows you to use any CPython module on PyPy
+
+* Embeds CPython into PyPy with CFFI
+
+* Numpy arrays can be shared between PyPy and CPython
+
+PyMetabiosis
+
+
+|scriptsize|
+
+.. sourcecode:: python
+
+from pymetabiosis import import_module
+
+cpython_virtualenv_path = 
+/home/rguillebert/.virtualenvs/venv/bin/activate_this.py
+
+builtin = import_module(__builtin__)
+
+# Activate a virtualenv for the cpython interpreter
+builtin.execfile(cpython_virtualenv_path,
+{__file__ : cpython_virtualenv_path}
+)
+
+pylab = import_module(matplotlib.pylab)
+
+pylab.plot([1, 2, 3, 4])
+pylab.show()
+
+|end_scriptsize|
+
 JitPy
 -
 
 * Work in progress
 
+* Embeds PyPy into CPython
+
+* Provides a decorator that allows you to run specific functions on PyPy
+
+* Is used the same way as numba, but different performance caracteristics
+
+JitPy
+-
+
+|scriptsize|
+
+.. sourcecode:: python
+
+from jitpy import setup
+setup('path-to-pypy-home')
+from jitpy.wrapper import jittify
+
+@jittify([int, float], float)
+def func(count, no):
+s = 0
+for i in range(count):
+   s += no
+return s
+
+func(10, 1.2)
+
+|end_scriptsize|
+
 Thank You
 -
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add new topics

2014-12-04 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5477:b636f7bce759
Date: 2014-12-04 14:18 +0530
http://bitbucket.org/pypy/extradoc/changeset/b636f7bce759/

Log:Add new topics

diff --git a/talk/scipyindia2014/talk.rst b/talk/scipyindia2014/talk.rst
--- a/talk/scipyindia2014/talk.rst
+++ b/talk/scipyindia2014/talk.rst
@@ -96,4 +96,15 @@
 
 * ~80% of the numpy tests are passing
 
-* XXX
+* Most of numpy is there
+
+* XXX is missing
+
+NumPyPy performance
+---
+
+PyMetabiosis
+
+
+JitPy
+-
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: First WIP for the Scipy India talk

2014-12-03 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5473:6790ce64ab6c
Date: 2014-12-03 17:40 +0100
http://bitbucket.org/pypy/extradoc/changeset/6790ce64ab6c/

Log:First WIP for the Scipy India talk

diff --git a/talk/scipyindia2014/talk.rst b/talk/scipyindia2014/talk.rst
new file mode 100644
--- /dev/null
+++ b/talk/scipyindia2014/talk.rst
@@ -0,0 +1,79 @@
+=
+PyPy and the scientific stack
+=
+
+Introduction
+
+
+* PyPy contributor
+
+* Hired to work on NumPyPy
+
+* Interested in library compatibility
+
+* @rguillebert on twitter, feel free to send me questions
+
+* Software consultant
+
+* Feel free to interrupt me
+
+PyPy
+
+
+* PyPy is an implementation of the Python language
+
+* Speed is one of its main advantages
+
+* Compatibility is very important to us
+
+Speed
+-
+
+* XXX : Insert speed.pypy.org screenshot
+
+Python
+--
+
+* Python is a great language
+
+* Very dynamic
+
+* Easy to introspect (pdb is just another Python module)
+
+* Considered slow
+
+How to get performance out of Python code ?
+---
+
+* Rewrite your code in C
+
+* Rewrite your code in Cython
+
+* Rewrite your code in some subset/dialect of Python like Numba
+
+* Just write Python and use PyPy, pay only the cost of what you use
+
+PyPy And C
+--
+
+* PyPy is pretty good at interacting with C code with cffi
+
+* C extensions written using the Python C API can work, but they're slow and 
support is incomplete
+
+* We have ideas to help with that in some use cases
+
+Python C API
+
+
+* Leaks way too many implementation details (refcounting, PyObject structure 
fields)
+
+* Makes it hard to improve Python while supporting 100% of the API
+
+* Should we have a new C API ?
+
+NumPyPy
+---
+
+* ~80% of the numpy tests are passing
+
+* XXX
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Progress

2014-12-03 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5476:dc90c5848fd0
Date: 2014-12-04 07:28 +0530
http://bitbucket.org/pypy/extradoc/changeset/dc90c5848fd0/

Log:Progress

diff --git a/talk/scipyindia2014/talk.rst b/talk/scipyindia2014/talk.rst
--- a/talk/scipyindia2014/talk.rst
+++ b/talk/scipyindia2014/talk.rst
@@ -56,16 +56,25 @@
 
 * Rewrite your code in some subset/dialect of Python like Numba
 
-* Just write Python and use PyPy, pay only the cost of what you use
+* Just write Python and use PyPy, only pay the cost of what you use
 
-PyPy And C
---
+PyPy and C (1/2)
+
 
-* PyPy is pretty good at interacting with C code with cffi
+* PyPy is pretty good at interacting with C code now, thanks to CFFI
+
+* CFFI is the easiest tool to I've used so far
+
+* Very fast on PyPy, fast enough on CPython
+
+* Used by NumPyPy
 
 * With CFFI you can call C code from Python and expose Python functions to C 
 
-  - This means you can create your own C API in pure python !
+  - This means you can create your own C API in pure Python !
+
+PyPy and C (2/2)
+
 
 * It is now possible to embed PyPy in a C application (uWSGI)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add the rst2beamer boilerplate

2014-12-03 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5475:f56bf45a654e
Date: 2014-12-04 02:25 +0100
http://bitbucket.org/pypy/extradoc/changeset/f56bf45a654e/

Log:Add the rst2beamer boilerplate

diff --git a/talk/scipyindia2014/Makefile b/talk/scipyindia2014/Makefile
new file mode 100644
--- /dev/null
+++ b/talk/scipyindia2014/Makefile
@@ -0,0 +1,18 @@
+# you can find rst2beamer.py here:
+# https://bitbucket.org/antocuni/env/raw/default/bin/rst2beamer.py
+
+# WARNING: to work, it needs this patch for docutils
+# 
https://sourceforge.net/tracker/?func=detailatid=422032aid=1459707group_id=38414
+
+talk.pdf: talk.rst author.latex stylesheet.latex
+   python `which rst2beamer.py` --stylesheet=stylesheet.latex 
--documentoptions=14pt talk.rst talk.latex || exit
+   #/home/antocuni/.virtualenvs/rst2beamer/bin/python `which 
rst2beamer.py` --stylesheet=stylesheet.latex --documentoptions=14pt talk.rst 
talk.latex || exit
+   sed 's/\\date{}/\\input{author.latex}/' -i talk.latex || exit
+   #sed 's/\\maketitle/\\input{title.latex}/' -i talk.latex || exit
+   pdflatex talk.latex  || exit
+
+view: talk.pdf
+   evince talk.pdf 
+
+xpdf: talk.pdf
+   xpdf talk.pdf 
diff --git a/talk/scipyindia2014/author.latex b/talk/scipyindia2014/author.latex
new file mode 100644
--- /dev/null
+++ b/talk/scipyindia2014/author.latex
@@ -0,0 +1,9 @@
+\definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0}
+
+\title[PyPy and the scientific stack]{PyPy and the scientific stack}
+\author[rguillebert]
+{Romain Guillebert\\
+\includegraphics[width=80px]{../img/py-web-new.png}}
+
+\institute{Scipy India 2014}
+\date{December 7th, 2014}
diff --git a/talk/scipyindia2014/beamerdefs.txt 
b/talk/scipyindia2014/beamerdefs.txt
new file mode 100644
--- /dev/null
+++ b/talk/scipyindia2014/beamerdefs.txt
@@ -0,0 +1,108 @@
+.. colors
+.. ===
+
+.. role:: green
+.. role:: red
+
+
+.. general useful commands
+.. ===
+
+.. |pause| raw:: latex
+
+   \pause
+
+.. |small| raw:: latex
+
+   {\small
+
+.. |end_small| raw:: latex
+
+   }
+
+.. |scriptsize| raw:: latex
+
+   {\scriptsize
+
+.. |end_scriptsize| raw:: latex
+
+   }
+
+.. |strike| raw:: latex
+
+   \sout{
+
+.. closed bracket
+.. ===
+
+.. || raw:: latex
+
+   }
+
+
+.. example block
+.. ===
+
+.. |example| raw:: latex
+
+   \begin{exampleblock}{
+
+
+.. |end_example| raw:: latex
+
+   \end{exampleblock}
+
+
+
+.. alert block
+.. ===
+
+.. |alert| raw:: latex
+
+   \begin{alertblock}{
+
+
+.. |end_alert| raw:: latex
+
+   \end{alertblock}
+
+
+
+.. columns
+.. ===
+
+.. |column1| raw:: latex
+
+   \begin{columns}
+  \begin{column}{0.45\textwidth}
+
+.. |column2| raw:: latex
+
+  \end{column}
+  \begin{column}{0.45\textwidth}
+
+
+.. |end_columns| raw:: latex
+
+  \end{column}
+   \end{columns}
+
+
+
+.. |snake| image:: ../../img/py-web-new.png
+   :scale: 15%
+   
+
+
+.. nested blocks
+.. ===
+
+.. |nested| raw:: latex
+
+   \begin{columns}
+  \begin{column}{0.85\textwidth}
+
+.. |end_nested| raw:: latex
+
+  \end{column}
+   \end{columns}
diff --git a/talk/scipyindia2014/stylesheet.latex 
b/talk/scipyindia2014/stylesheet.latex
new file mode 100644
--- /dev/null
+++ b/talk/scipyindia2014/stylesheet.latex
@@ -0,0 +1,9 @@
+\setbeamercovered{transparent}
+\setbeamertemplate{navigation symbols}{}
+
+\definecolor{darkgreen}{rgb}{0, 0.5, 0.0}
+\newcommand{\docutilsrolegreen}[1]{\color{darkgreen}#1\normalcolor}
+\newcommand{\docutilsrolered}[1]{\color{red}#1\normalcolor}
+
+\newcommand{\green}[1]{\color{darkgreen}#1\normalcolor}
+\newcommand{\red}[1]{\color{red}#1\normalcolor}
diff --git a/talk/scipyindia2014/talk.rst b/talk/scipyindia2014/talk.rst
--- a/talk/scipyindia2014/talk.rst
+++ b/talk/scipyindia2014/talk.rst
@@ -65,7 +65,7 @@
 
 * With CFFI you can call C code from Python and expose Python functions to C 
 
-  - this means that you can create your own C API in pure python !
+  - This means you can create your own C API in pure python !
 
 * It is now possible to embed PyPy in a C application (uWSGI)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Progress

2014-12-03 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5474:70b9b4be4e0d
Date: 2014-12-04 02:13 +0100
http://bitbucket.org/pypy/extradoc/changeset/70b9b4be4e0d/

Log:Progress

diff --git a/talk/scipyindia2014/talk.rst b/talk/scipyindia2014/talk.rst
--- a/talk/scipyindia2014/talk.rst
+++ b/talk/scipyindia2014/talk.rst
@@ -26,11 +26,6 @@
 
 * Compatibility is very important to us
 
-Speed
--
-
-* XXX : Insert speed.pypy.org screenshot
-
 Python
 --
 
@@ -42,6 +37,16 @@
 
 * Considered slow
 
+Speed
+-
+
+* XXX : Insert speed.pypy.org screenshot
+
+Demo
+
+
+* Real-time edge detection
+
 How to get performance out of Python code ?
 ---
 
@@ -58,6 +63,12 @@
 
 * PyPy is pretty good at interacting with C code with cffi
 
+* With CFFI you can call C code from Python and expose Python functions to C 
+
+  - this means that you can create your own C API in pure python !
+
+* It is now possible to embed PyPy in a C application (uWSGI)
+
 * C extensions written using the Python C API can work, but they're slow and 
support is incomplete
 
 * We have ideas to help with that in some use cases
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Planning for today

2014-10-24 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5448:5fd33e7c6588
Date: 2014-10-24 12:06 +0200
http://bitbucket.org/pypy/extradoc/changeset/5fd33e7c6588/

Log:Planning for today

diff --git a/sprintinfo/warsaw-2014/planning.txt 
b/sprintinfo/warsaw-2014/planning.txt
--- a/sprintinfo/warsaw-2014/planning.txt
+++ b/sprintinfo/warsaw-2014/planning.txt
@@ -3,32 +3,32 @@
 
 * cffi.verify dlopen flag - TO BE MERGED
 
-* PyPy/CPython Bridge (Romain, kostia) - IN PROGRESS
+* PyPy/CPython Bridge (Romain, kostia) - MORE PROGRESS
 
-* Profiler (Antonio, Maciej) - Working around libunwind limitations
+* Profiler (Antonio, Armin) - IN PROGRESS
 
 * Merge improve-docs (Manuel, Ronan) - IN PROGRESS
 
-* Merge kill-multimethod remove-remaining-smm  (Manuel, Antonio) - FIXING 
NONSENSE
+* Merge kill-multimethod remove-remaining-smm  (Manuel, Antonio, fijal) - 
MERGED remove-remaining-smm, kill-multimethod WAITING FOR REVIEW
 
-* STM presentation (Everybody) - AT SOME POINT
+* STM presentation (Everybody) - DONE
 
-* Refactor annotator/rtyper (Ronan?) - NOT YET
+* Refactor annotator/rtyper (Ronan?) - LOOKING FOR PAIRING
 
 * Python 3.3 - IN PROGRESS
 
-* Everything (Armin) - HAVEN'T FIXED EVERYTHING YET
-
-* getting stuff run on pypy - success, stuff runs 7x faster DONE
-
-* look into merging gc pinning (fijal, arigo) - ALMOST READY
+* look into merging gc pinning (fijal, arigo) - ALMOST READY, more debugging 
needed
 
 * investigate -fPIC slowdown (fijal, arigo) - IN PROGRESS, complete mess
 
-* NumPyPy discussion (everybody?)
+* NumPyPy discussion (everybody) DONE
 
 * Trying stuff on PyPy-STM (Antonio, Kostia)
 
+* convincing anto why resume refactoring is a good idea
+
+* switchify chains of guard_value (Armin, Romain...)
+
 People
 =
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Planning for today

2014-10-23 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5447:572d3874591d
Date: 2014-10-23 12:00 +0200
http://bitbucket.org/pypy/extradoc/changeset/572d3874591d/

Log:Planning for today

diff --git a/sprintinfo/warsaw-2014/planning.txt 
b/sprintinfo/warsaw-2014/planning.txt
--- a/sprintinfo/warsaw-2014/planning.txt
+++ b/sprintinfo/warsaw-2014/planning.txt
@@ -1,29 +1,33 @@
 Topics
-=
+==
 
 * cffi.verify dlopen flag - TO BE MERGED
 
 * PyPy/CPython Bridge (Romain, kostia) - IN PROGRESS
 
-* Profiler (Antonio, Maciej?) - IN PROGRESS
+* Profiler (Antonio, Maciej) - Working around libunwind limitations
 
-* Merge improve-docs (Manuel, Ronan)
+* Merge improve-docs (Manuel, Ronan) - IN PROGRESS
 
-* Merge kill-multimethod remove-remaining-smm  (Manuel, Antonio)
+* Merge kill-multimethod remove-remaining-smm  (Manuel, Antonio) - FIXING 
NONSENSE
 
-* STM presentation (Everybody)
+* STM presentation (Everybody) - AT SOME POINT
 
-* Refactor annotator/rtyper (Ronan)
+* Refactor annotator/rtyper (Ronan?) - NOT YET
 
 * Python 3.3 - IN PROGRESS
 
-* Jitviewer redesign discussion
+* Everything (Armin) - HAVEN'T FIXED EVERYTHING YET
 
-* Everything (Armin)
+* getting stuff run on pypy - success, stuff runs 7x faster DONE
 
-* getting stuff run on pypy (antonin, fijal)
+* look into merging gc pinning (fijal, arigo) - ALMOST READY
 
-* look into merging gc pinning (fijal, arigo)
+* investigate -fPIC slowdown (fijal, arigo) - IN PROGRESS, complete mess
+
+* NumPyPy discussion (everybody?)
+
+* Trying stuff on PyPy-STM (Antonio, Kostia)
 
 People
 =
@@ -35,4 +39,3 @@
 Romain
 Manuel
 Maciej
-Antonin
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Planning for today

2014-10-22 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5446:57fa4f6b67b9
Date: 2014-10-22 11:10 +0200
http://bitbucket.org/pypy/extradoc/changeset/57fa4f6b67b9/

Log:Planning for today

diff --git a/sprintinfo/warsaw-2014/planning.txt 
b/sprintinfo/warsaw-2014/planning.txt
--- a/sprintinfo/warsaw-2014/planning.txt
+++ b/sprintinfo/warsaw-2014/planning.txt
@@ -1,36 +1,38 @@
 Topics
-==
+=
 
-* cffi.verify dlopen flag (Romain)
+* cffi.verify dlopen flag - TO BE MERGED
 
-* PyPy/CPython Bridge (Romain)
+* PyPy/CPython Bridge (Romain, kostia) - IN PROGRESS
 
-* Pandas on PyPy (Romain, Kostia)
+* Profiler (Antonio, Maciej?) - IN PROGRESS
 
-* Profiler (Antonio, Maciej?)
+* Merge improve-docs (Manuel, Ronan)
 
-* Merge improve-docs (Manuel)
-
-* Merge kill-multimethod remove-remaining-smm  (Manuel)
+* Merge kill-multimethod remove-remaining-smm  (Manuel, Antonio)
 
 * STM presentation (Everybody)
 
 * Refactor annotator/rtyper (Ronan)
 
-* Python 3.3 (Valentina, Manuel)
+* Python 3.3 - IN PROGRESS
 
 * Jitviewer redesign discussion
 
 * Everything (Armin)
 
+* getting stuff run on pypy (antonin, fijal)
+
+* look into merging gc pinning (fijal, arigo)
+
 People
-==
+=
 
 Antonio
 Armin
 Kostia
 Ronan
-Valentina
 Romain
 Manuel
-Maciej (not here yet)
+Maciej
+Antonin
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Standardize quotes

2014-10-21 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5444:285d9ba3bf75
Date: 2014-10-12 01:37 +0100
http://bitbucket.org/pypy/extradoc/changeset/285d9ba3bf75/

Log:Standardize quotes

diff --git a/talk/pyconie2014/talk.pdf b/talk/pyconie2014/talk.pdf
index 
27f9e9138b4f8679dfe509270a43bfc40ea36a68..37471fc682314053e975c0a3fb2465f815ebbf06
GIT binary patch

[cut]

diff --git a/talk/pyconie2014/talk.rst b/talk/pyconie2014/talk.rst
--- a/talk/pyconie2014/talk.rst
+++ b/talk/pyconie2014/talk.rst
@@ -114,9 +114,9 @@
 Success stories
 ---
 
-Magnetic is the leader in online search retargeting, with a large, high 
volume, performance-critical platform written in Python. [...] 
+Magnetic is the leader in online search retargeting, with a large, high 
volume, performance-critical platform written in Python. [...] 
 
-The Magnetic bidders were ported from CPython to PyPy, yielding an overall 
30% performance gain.
+The Magnetic bidders were ported from CPython to PyPy, yielding an overall 
30% performance gain.
 
 - Julian Berman
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add planning for today

2014-10-21 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5445:49e724edda7a
Date: 2014-10-21 11:58 +0200
http://bitbucket.org/pypy/extradoc/changeset/49e724edda7a/

Log:Add planning for today

diff --git a/sprintinfo/warsaw-2014/planning.txt 
b/sprintinfo/warsaw-2014/planning.txt
new file mode 100644
--- /dev/null
+++ b/sprintinfo/warsaw-2014/planning.txt
@@ -0,0 +1,36 @@
+Topics
+==
+
+* cffi.verify dlopen flag (Romain)
+
+* PyPy/CPython Bridge (Romain)
+
+* Pandas on PyPy (Romain, Kostia)
+
+* Profiler (Antonio, Maciej?)
+
+* Merge improve-docs (Manuel)
+
+* Merge kill-multimethod remove-remaining-smm  (Manuel)
+
+* STM presentation (Everybody)
+
+* Refactor annotator/rtyper (Ronan)
+
+* Python 3.3 (Valentina, Manuel)
+
+* Jitviewer redesign discussion
+
+* Everything (Armin)
+
+People
+==
+
+Antonio
+Armin
+Kostia
+Ronan
+Valentina
+Romain
+Manuel
+Maciej (not here yet)
diff --git a/talk/pyconie2014/talk.pdf b/talk/pyconie2014/talk.pdf
index 
37471fc682314053e975c0a3fb2465f815ebbf06..748494720b5c056a3734955b2bbb4ad2f93692e4
GIT binary patch

[cut]

diff --git a/talk/pyconie2014/talk.rst b/talk/pyconie2014/talk.rst
--- a/talk/pyconie2014/talk.rst
+++ b/talk/pyconie2014/talk.rst
@@ -44,13 +44,15 @@
 
 - Removes overhead when unnecessary
 
-- But Python features which need require overhead remain available (frame 
introspection, pdb)
+- But Python features which require overhead remain available (frame 
introspection, pdb)
 
 Performance ?
 -
 
 - Things get done faster
 
+- Serve more requests per second
+
 - Lower latency
 
 - Less servers for the same performance
@@ -142,6 +144,15 @@
 
   Unbit
 
+Success stories
+---
+
+PyPy is an excellent choice for every pure Python project that depends on 
speed of execution of readable and maintainable large source code.
+[...]
+We had roughly a 2x speedup with PyPy over CPython.
+
+- Marko Tasic (Web and Data processing)
+
 Future
 --
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Improve talk

2014-10-11 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5429:b08eb1994574
Date: 2014-10-12 01:02 +0100
http://bitbucket.org/pypy/extradoc/changeset/b08eb1994574/

Log:Improve talk

diff --git a/talk/pyconie2014/talk.rst b/talk/pyconie2014/talk.rst
--- a/talk/pyconie2014/talk.rst
+++ b/talk/pyconie2014/talk.rst
@@ -14,8 +14,6 @@
 
 - Software consultant (hire me !)
 
-- Feel free to interrupt
-
 Introduction
 
 
@@ -40,42 +38,28 @@
 
 - Automatically generated tracing just-in-time compiler
 
+- Generates linear traces from loops
+
 - Generates efficient machine code based on runtime observations
 
 - Removes overhead when unnecessary
 
 - But Python features which need require overhead remain available (frame 
introspection, pdb)
 
-RPython

+Performance ?
+-
 
-- Subset of Python
+- Things get done faster
 
-- Made for writting virtual machines
+- Lower latency
 
-- Takes care of garbage collection and JIT compilation
-
-- A VM written in RPython doesn't have to know about the garbage collector
-
-- Minimal help from the VM is needed in order to have an efficient JIT (a few 
annotations)
+- Less servers for the same performance
 
 Demo
 
 
 - Real-time edge detection
 
-How

-
-- Generates linear traces from loops
-
-- Specializes traces on types
-
-- Removes boxing, integer objects become machine integers
-
-- If the type of the object is different from the type in the trace being 
executed, go back to the interpreter : guard failure
-
-- If a guard fails too many times, generate traces for the other types 
frequently encountered
 
 Compatibility
 -
@@ -127,6 +111,37 @@
 
 - Other tools could be built on top of it (Cython cffi backend ?)
 
+Success stories
+---
+
+Magnetic is the leader in online search retargeting, with a large, high 
volume, performance-critical platform written in Python. [...] 
+
+The Magnetic bidders were ported from CPython to PyPy, yielding an overall 
30% performance gain.
+
+- Julian Berman
+
+  magnetic.com
+
+Success stories
+---
+
+Currently we have improvements in raw performance (read: response times) 
that span from 8% to a pretty interesting 40%, but we have a peak of an 
astonishing 100-120% and even more.
+
+Take into the account that most of our apps are simple blocking-on-db 
ones, so a 2x increase is literally money.
+
+- Roberto De Ioris
+
+  Unbit
+
+Success stories
+---
+
+In addition to this our main (almost secret) objective was reducing 
resource usage of the application servers, which directly translates to being 
able to host more customers on the same server.
+
+- Roberto De Ioris
+
+  Unbit
+
 Future
 --
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add pdf

2014-10-11 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5430:5be33273a482
Date: 2014-10-12 01:02 +0100
http://bitbucket.org/pypy/extradoc/changeset/5be33273a482/

Log:Add pdf

diff --git a/talk/pyconie2014/talk.pdf b/talk/pyconie2014/talk.pdf
new file mode 100644
index 
..27f9e9138b4f8679dfe509270a43bfc40ea36a68
GIT binary patch

[cut]

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: More slides

2014-10-05 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5422:2e225431af6a
Date: 2014-10-01 16:20 +0200
http://bitbucket.org/pypy/extradoc/changeset/2e225431af6a/

Log:More slides

diff --git a/talk/pyconie2014/talk.rst b/talk/pyconie2014/talk.rst
--- a/talk/pyconie2014/talk.rst
+++ b/talk/pyconie2014/talk.rst
@@ -1,4 +1,4 @@
-.. include:: beamerdefs.tx
+.. include:: beamerdefs.txt
 
 PyPy : A fast Python Virtual Machine
 
@@ -73,4 +73,52 @@
 
 - If the type of the object is different from the type in the trace, go back 
to the interpreter : guard failure
 
-- If a guard fails too many times, optimize the trace for the other types 
frequently encountered
+- If a guard fails too many times, generate traces for the other types 
frequently encountered
+
+Compatibility
+-
+
+- Fully compatible with CPython 2.7  3.2 (minus bugs  implementation 
specific features)
+
+- Partial and slow support of the C-API
+
+- Alternatives might exist
+
+Ecosystem
+-
+
+- Just my opinion
+
+- We should move away from the C-API
+
+  * Makes assumptions on refcounting, object layout, the GIL
+
+  * The future of Python is bound to the future of CPython (a more than 20 
years old interpreter)
+
+  * It's hard for a new Python VM without C extension support to get traction 
(not only PyPy)
+
+- This doesn't mean we should lose Python's ability to interface with C easily
+
+CFFI
+
+
+- Where do we go from here ?
+
+- CFFI is a fairly new way of interacting with C in an implementation 
independant way
+
+- Very fast on PyPy
+
+- Decently fast on CPython
+
+- The Jython project is working on fast support
+
+CFFI
+
+
+- More convenient, safer, faster than ctypes
+
+- Python functions can be exposed to C easily
+
+- Already used by pyopenssl, psycopg2cffi, pygame_cffi, lxml_cffi
+
+- Other tools could be built on top of it (Cython cffi backend ?)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Update accomodation

2014-10-05 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5425:e020c4c36d7f
Date: 2014-10-05 21:03 +0200
http://bitbucket.org/pypy/extradoc/changeset/e020c4c36d7f/

Log:Update accomodation

diff --git a/sprintinfo/warsaw-2014/people.txt 
b/sprintinfo/warsaw-2014/people.txt
--- a/sprintinfo/warsaw-2014/people.txt
+++ b/sprintinfo/warsaw-2014/people.txt
@@ -11,8 +11,8 @@
  == ===
 Armin Rigo   20/10-28/10with fijal
 Maciej Fijalkowski   20/10-30/10private
-Romain Guillebert19/10-26-10???
-Manuel Jacob 20/10-26/10? (shared hotel room?)
+Romain Guillebert19/10-26-10ibis Reduta with mjacob
+Manuel Jacob 20/10-26/10ibis Reduta with rguillebert
 Kostia Lopuhin
 Antonio Cuni 20/10-26/10ibis Reduta 
http://www.ibis.com/gb/hotel-7125-ibis-warszawa-reduta/index.shtml
  == ===
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Merge heads

2014-10-05 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5424:12b314a72e1f
Date: 2014-10-05 21:00 +0200
http://bitbucket.org/pypy/extradoc/changeset/12b314a72e1f/

Log:Merge heads

diff --git a/sprintinfo/warsaw-2014/announcement.txt 
b/sprintinfo/warsaw-2014/announcement.txt
--- a/sprintinfo/warsaw-2014/announcement.txt
+++ b/sprintinfo/warsaw-2014/announcement.txt
@@ -38,8 +38,8 @@
 
 
 The sprint will happen within a room of Warsaw University.  The
-address is Pasteura 5 (which is a form of Pasteur street), room 550.
-The person of contact is Maciej Fijalkowski.
+address is Pasteura 5 (which is a form of Pasteur street), dept. of
+Physics, room 450.  The person of contact is Maciej Fijalkowski.
 
 
 --
diff --git a/sprintinfo/warsaw-2014/people.txt 
b/sprintinfo/warsaw-2014/people.txt
--- a/sprintinfo/warsaw-2014/people.txt
+++ b/sprintinfo/warsaw-2014/people.txt
@@ -9,7 +9,10 @@
  == ===
 Name  Arrive/Depart Accomodation 
  == ===
-Armin Rigo   20/10-2X/10with fijal?
+Armin Rigo   20/10-28/10with fijal
+Maciej Fijalkowski   20/10-30/10private
 Romain Guillebert19/10-26-10???
 Manuel Jacob 20/10-26/10? (shared hotel room?)
+Kostia Lopuhin
+Antonio Cuni 20/10-26/10ibis Reduta 
http://www.ibis.com/gb/hotel-7125-ibis-warszawa-reduta/index.shtml
  == ===
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Move the future slide to the end

2014-10-05 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5426:52815725aaa2
Date: 2014-10-05 22:11 +0200
http://bitbucket.org/pypy/extradoc/changeset/52815725aaa2/

Log:Move the future slide to the end

diff --git a/talk/pyconie2014/talk.rst b/talk/pyconie2014/talk.rst
--- a/talk/pyconie2014/talk.rst
+++ b/talk/pyconie2014/talk.rst
@@ -86,15 +86,6 @@
 
 - Alternatives might exist
 
-Future
---
-
-- More Python 3
-
-- NumPyPy
-
-- STM
-
 Ecosystem
 -
 
@@ -136,6 +127,17 @@
 
 - Other tools could be built on top of it (Cython cffi backend ?)
 
+Future
+--
+
+- Python 3.3
+
+- NumPyPy
+
+- STM
+
+- You can donate to help the progress of these features : pypy.org
+
 Questions
 -
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add the beginning of my PyCon IE talk

2014-09-29 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5414:8e809924b51f
Date: 2014-09-24 17:11 +0200
http://bitbucket.org/pypy/extradoc/changeset/8e809924b51f/

Log:Add the beginning of my PyCon IE talk

diff --git a/talk/pyconie2014/Makefile b/talk/pyconie2014/Makefile
new file mode 100644
--- /dev/null
+++ b/talk/pyconie2014/Makefile
@@ -0,0 +1,18 @@
+# you can find rst2beamer.py here:
+# https://bitbucket.org/antocuni/env/raw/default/bin/rst2beamer.py
+
+# WARNING: to work, it needs this patch for docutils
+# 
https://sourceforge.net/tracker/?func=detailatid=422032aid=1459707group_id=38414
+
+talk.pdf: talk.rst author.latex stylesheet.latex
+   python `which rst2beamer.py` --stylesheet=stylesheet.latex 
--documentoptions=14pt talk.rst talk.latex || exit
+   #/home/antocuni/.virtualenvs/rst2beamer/bin/python `which 
rst2beamer.py` --stylesheet=stylesheet.latex --documentoptions=14pt talk.rst 
talk.latex || exit
+   sed 's/\\date{}/\\input{author.latex}/' -i talk.latex || exit
+   #sed 's/\\maketitle/\\input{title.latex}/' -i talk.latex || exit
+   pdflatex talk.latex  || exit
+
+view: talk.pdf
+   evince talk.pdf 
+
+xpdf: talk.pdf
+   xpdf talk.pdf 
diff --git a/talk/pyconie2014/author.latex b/talk/pyconie2014/author.latex
new file mode 100644
--- /dev/null
+++ b/talk/pyconie2014/author.latex
@@ -0,0 +1,9 @@
+\definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0}
+
+\title[PyPy : A fast Python Virtual Machine]{PyPy : A fast Python Virtual 
Machine}
+\author[rguillebert]
+{Romain Guillebert\\
+\includegraphics[width=80px]{../img/py-web-new.png}}
+
+\institute{Pycon IE}
+\date{October 12th, 2014}
diff --git a/talk/pyconie2014/beamerdefs.txt b/talk/pyconie2014/beamerdefs.txt
new file mode 100644
--- /dev/null
+++ b/talk/pyconie2014/beamerdefs.txt
@@ -0,0 +1,108 @@
+.. colors
+.. ===
+
+.. role:: green
+.. role:: red
+
+
+.. general useful commands
+.. ===
+
+.. |pause| raw:: latex
+
+   \pause
+
+.. |small| raw:: latex
+
+   {\small
+
+.. |end_small| raw:: latex
+
+   }
+
+.. |scriptsize| raw:: latex
+
+   {\scriptsize
+
+.. |end_scriptsize| raw:: latex
+
+   }
+
+.. |strike| raw:: latex
+
+   \sout{
+
+.. closed bracket
+.. ===
+
+.. || raw:: latex
+
+   }
+
+
+.. example block
+.. ===
+
+.. |example| raw:: latex
+
+   \begin{exampleblock}{
+
+
+.. |end_example| raw:: latex
+
+   \end{exampleblock}
+
+
+
+.. alert block
+.. ===
+
+.. |alert| raw:: latex
+
+   \begin{alertblock}{
+
+
+.. |end_alert| raw:: latex
+
+   \end{alertblock}
+
+
+
+.. columns
+.. ===
+
+.. |column1| raw:: latex
+
+   \begin{columns}
+  \begin{column}{0.45\textwidth}
+
+.. |column2| raw:: latex
+
+  \end{column}
+  \begin{column}{0.45\textwidth}
+
+
+.. |end_columns| raw:: latex
+
+  \end{column}
+   \end{columns}
+
+
+
+.. |snake| image:: ../../img/py-web-new.png
+   :scale: 15%
+   
+
+
+.. nested blocks
+.. ===
+
+.. |nested| raw:: latex
+
+   \begin{columns}
+  \begin{column}{0.85\textwidth}
+
+.. |end_nested| raw:: latex
+
+  \end{column}
+   \end{columns}
diff --git a/talk/pyconie2014/speed.png b/talk/pyconie2014/speed.png
new file mode 100644
index 
..4640c76f8a665af1c414dc4c4ca22be3bd8ff360
GIT binary patch

[cut]

diff --git a/talk/pyconie2014/stylesheet.latex 
b/talk/pyconie2014/stylesheet.latex
new file mode 100644
--- /dev/null
+++ b/talk/pyconie2014/stylesheet.latex
@@ -0,0 +1,9 @@
+\setbeamercovered{transparent}
+\setbeamertemplate{navigation symbols}{}
+
+\definecolor{darkgreen}{rgb}{0, 0.5, 0.0}
+\newcommand{\docutilsrolegreen}[1]{\color{darkgreen}#1\normalcolor}
+\newcommand{\docutilsrolered}[1]{\color{red}#1\normalcolor}
+
+\newcommand{\green}[1]{\color{darkgreen}#1\normalcolor}
+\newcommand{\red}[1]{\color{red}#1\normalcolor}
diff --git a/talk/pyconie2014/talk.rst b/talk/pyconie2014/talk.rst
new file mode 100644
--- /dev/null
+++ b/talk/pyconie2014/talk.rst
@@ -0,0 +1,34 @@
+PyPy : A fast Python Virtual Machine
+
+
+Me
+--
+
+- rguillebert on twitter and irc
+
+- PyPy contributor since 2011
+
+- NumPyPy contributor
+
+- Software consultant (hire me !)
+
+- Feel free to interrupt
+
+Introduction
+
+
+- PyPy is a fast, compliant alternative implementation of the Python language
+
+- Aims to reach the best performance possible without changing the syntax or 
semantics
+
+- Supports x86, x86_64, ARM
+
+- Production ready
+
+- MIT Licensed
+
+Speed
+-
+
+.. image:: speed.png
+   :scale: 37%
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add myself

2014-09-29 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5416:2cf1024f1867
Date: 2014-09-29 22:21 +0200
http://bitbucket.org/pypy/extradoc/changeset/2cf1024f1867/

Log:Add myself

diff --git a/sprintinfo/warsaw-2014/people.txt 
b/sprintinfo/warsaw-2014/people.txt
--- a/sprintinfo/warsaw-2014/people.txt
+++ b/sprintinfo/warsaw-2014/people.txt
@@ -10,4 +10,5 @@
 Name  Arrive/Depart Accomodation 
  == ===
 Armin Rigo   20/10-2X/10with fijal?
+Romain Guillebert19/10-26-10???
  == ===
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add more slides

2014-09-29 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5415:1d748d9bdbc8
Date: 2014-09-29 22:20 +0200
http://bitbucket.org/pypy/extradoc/changeset/1d748d9bdbc8/

Log:Add more slides

diff --git a/talk/pyconie2014/talk.rst b/talk/pyconie2014/talk.rst
--- a/talk/pyconie2014/talk.rst
+++ b/talk/pyconie2014/talk.rst
@@ -1,3 +1,5 @@
+.. include:: beamerdefs.tx
+
 PyPy : A fast Python Virtual Machine
 
 
@@ -32,3 +34,43 @@
 
 .. image:: speed.png
:scale: 37%
+
+Speed
+-
+
+- Automatically generated tracing just-in-time compiler
+
+- Generates efficient machine code based on runtime observations
+
+- Removes overhead when unnecessary
+
+- But these Python features remain available (pdb)
+
+RPython
+---
+
+- Subset of Python
+
+- Made for writting virtual machines
+
+- Takes care of garbage collection and JIT compilation
+
+- A VM written in RPython doesn't have to know about the garbage collector
+
+- Minimal help from the VM is needed in order to have an efficient JIT (a few 
annotations)
+
+Demo
+
+
+- Real-time edge detection
+
+How
+---
+
+- Removes boxing, integer objects become machine integers
+
+- Specializes trace on types, helps speed-up method lookup
+
+- If the type of the object is different from the type in the trace, go back 
to the interpreter : guard failure
+
+- If a guard fails too many times, optimize the trace for the other types 
frequently encountered
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: typos

2014-09-12 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5395:0a13f83cb05d
Date: 2014-09-12 21:17 +0200
http://bitbucket.org/pypy/extradoc/changeset/0a13f83cb05d/

Log:typos

diff --git a/talk/pycon2015/status/abstract.rst 
b/talk/pycon2015/status/abstract.rst
--- a/talk/pycon2015/status/abstract.rst
+++ b/talk/pycon2015/status/abstract.rst
@@ -11,11 +11,11 @@
 we have achieved during the two years between talks. We would like to cover
 advancements in the PyPy performance landscape, but more importantly how
 we're addresssing the community needs and building the ecosystem. These days
-a lot of libraries that used to bind to C using CPython C API are either
+a lot of libraries that used to bind to C using the CPython C API are either
 using cffi or have alternatives using cffi.
 
 We would also like to walk through a few success stories that we have
-experienced. Unforunately the biggest chunk of PyPy clients are very
+experienced. Unfortunately the biggest chunk of PyPy clients are very
 secretive (e.g. trading companies), but we can still present a few case 
studies.
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add the talk description (WIP)

2014-09-12 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5396:f584b11b5444
Date: 2014-09-12 23:24 +0200
http://bitbucket.org/pypy/extradoc/changeset/f584b11b5444/

Log:Add the talk description (WIP)

diff --git a/talk/pycon2015/status/abstract.rst 
b/talk/pycon2015/status/abstract.rst
--- a/talk/pycon2015/status/abstract.rst
+++ b/talk/pycon2015/status/abstract.rst
@@ -1,6 +1,17 @@
 PyPy - the last 2 years of progress
 ===
 
+Description (one paragraph, 400 chars max)
+--
+
+This talk describes what happened in the PyPy ecosystem in the last 2 years, a
+timeframe in which PyPy has been successfully deployed multiple times while
+yielding interesting performance improvements and a timeframe in which more
+libraries started being compatible with PyPy through the use of cffi.
+
+Detailed Abstract
+-
+
 PyPy has been in the works for more than ten years and has reached relative
 maturity with more and more libraries working under PyPy and more deployments
 happening. Right now it entertains between 0.5-1.0% of PyPI package downloads
@@ -19,21 +30,3 @@
 secretive (e.g. trading companies), but we can still present a few case 
studies.
 
 
-
-Abstract
-
-
-This talk will cover what has happened in the PyPy world during the last 2
-years :
-
-- Progress in Python 3 support and Numpy support
-
-- Performance improvements
-
-- An attempt to remove the GIL using Software Transactional Memory
-
-- CFFI : The best way to interface with C code on PyPy
-
-- Status of the crowdfunding
-
-- ARM
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Draft of the status of PyPy proposal for PyCon 2015

2014-09-08 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5391:e97b47cafad7
Date: 2014-09-08 18:15 +0200
http://bitbucket.org/pypy/extradoc/changeset/e97b47cafad7/

Log:Draft of the status of PyPy proposal for PyCon 2015

diff --git a/talk/pycon2015/status/abstract.rst 
b/talk/pycon2015/status/abstract.rst
new file mode 100644
--- /dev/null
+++ b/talk/pycon2015/status/abstract.rst
@@ -0,0 +1,14 @@
+Status of PyPy and its ecosystem
+
+
+Description
+---
+
+PyPy is a fast alternative implementation of Python. This talk will describe
+what happened in the PyPy ecosystem in the last 2 years and what the future
+holds. Topics such as JIT improvements, garbage collection, CFFI, Numpy, STM
+and Python 3 will be covered.
+
+Abstract
+
+
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add the beginning of an abstract

2014-09-08 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5392:b4c2529c96c0
Date: 2014-09-08 20:54 +0200
http://bitbucket.org/pypy/extradoc/changeset/b4c2529c96c0/

Log:Add the beginning of an abstract

diff --git a/talk/pycon2015/status/abstract.rst 
b/talk/pycon2015/status/abstract.rst
--- a/talk/pycon2015/status/abstract.rst
+++ b/talk/pycon2015/status/abstract.rst
@@ -12,3 +12,17 @@
 Abstract
 
 
+This talk will cover what has happened in the PyPy world during the last 2
+years :
+
+- Progress in Python 3 support and Numpy support
+
+- Performance improvements
+
+- An attempt to remove the GIL using Software Transactional Memory
+
+- CFFI : The best way to interface with C code on PyPy
+
+- Status of the crowdfunding
+
+- ARM
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add info

2014-07-22 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5363:ae1bfc1320b2
Date: 2014-07-22 12:13 +0200
http://bitbucket.org/pypy/extradoc/changeset/ae1bfc1320b2/

Log:Add info

diff --git a/talk/ep2014/status/talk.pdf b/talk/ep2014/status/talk.pdf
index 
f9532b263b7bf1aa53ba0d807a875af9991c6a39..8526e0aa7ea79199e3af9c68b27da1de432d
GIT binary patch

[cut]

diff --git a/talk/ep2014/status/talk.rst b/talk/ep2014/status/talk.rst
--- a/talk/ep2014/status/talk.rst
+++ b/talk/ep2014/status/talk.rst
@@ -4,6 +4,17 @@
 PyPy Status
 
 
+Who Am I
+
+
+* rguillebert on twitter and irc
+
+* GSoC student on PyPy/Cython
+
+* PyPy contributor since 2011
+
+* Worked on Py3k and Numpy
+
 PyPy is not dead
 
 
@@ -256,7 +267,7 @@
 
 - Preliminary versions of pypy-jit-stm available
 
-- The overhead is still a bit too high and hard to precict
+- The overhead is still a bit too high and hard to predict
 
 - Lots of polishing needed
 
@@ -272,4 +283,6 @@
 
 - http://morepypy.blogspot.com/
 
+- #p...@freenode.net
+
 - Any question?
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add baroquesoftware

2014-07-22 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5364:3334209f26d3
Date: 2014-07-22 12:22 +0200
http://bitbucket.org/pypy/extradoc/changeset/3334209f26d3/

Log:Add baroquesoftware

diff --git a/talk/ep2014/status/talk.pdf b/talk/ep2014/status/talk.pdf
index 
8526e0aa7ea79199e3af9c68b27da1de432d..ddbec1104c2a94e56c7ec21e61c879b534382932
GIT binary patch

[cut]

diff --git a/talk/ep2014/status/talk.rst b/talk/ep2014/status/talk.rst
--- a/talk/ep2014/status/talk.rst
+++ b/talk/ep2014/status/talk.rst
@@ -143,6 +143,8 @@
   improving support in parts of the Python or non-Python interpreters,
   etc.
 
+- http://baroquesoftware.com
+
 Current status
 ---
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Kill stuff

2014-07-22 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5365:dacc44cdb7af
Date: 2014-07-22 13:57 +0200
http://bitbucket.org/pypy/extradoc/changeset/dacc44cdb7af/

Log:Kill stuff

diff --git a/talk/ep2014/status/talk.pdf b/talk/ep2014/status/talk.pdf
index 
ddbec1104c2a94e56c7ec21e61c879b534382932..447f7b485ff254fb76dc366dbce2dc84e936e122
GIT binary patch

[cut]

diff --git a/talk/ep2014/status/talk.rst b/talk/ep2014/status/talk.rst
--- a/talk/ep2014/status/talk.rst
+++ b/talk/ep2014/status/talk.rst
@@ -9,11 +9,11 @@
 
 * rguillebert on twitter and irc
 
+* PyPy contributor since 2011
+
 * GSoC student on PyPy/Cython
 
-* PyPy contributor since 2011
-
-* Worked on Py3k and Numpy
+* Worked on Py3k and Numpy support
 
 PyPy is not dead
 
@@ -26,12 +26,6 @@
 
 - PyPy is healthy and alive
 
-|pause|
-
-- WARNING: This talk is boring
-
-  * it just works
-
 What is PyPy?
 --
 
@@ -49,11 +43,6 @@
 
   - **FAST**
 
-* Whatever (dynamic) language you want
-
-  - smalltalk, prolog, PHP, javascript, ...
-
-
 PyPy: past two years (1)
 -
 
@@ -63,16 +52,12 @@
 
   * stackless + JIT (eventlet, gevent, ...)
 
-|pause|
-
 - PyPy 2.1 (July 2013)
 
   * stable ARM
 
   * py3k (3.2.3), numpy, general improvements, bugfixes
 
-|pause|
-
 - PyPy 2.2 (November 2013)
 
   * incremental GC, faster JSON
@@ -87,13 +72,13 @@
 
 - PyPy 2.3 (May 2014)
 
-- Lot of internal refactoring
+  * Lot of internal refactoring
 
-- C API for embedding
+  * C API for embedding
 
-  * pypy + uWSGI (thanks to Roberto De Ioris)
+- pypy + uWSGI (thanks to Roberto De Ioris)
 
-- the usual, boring, general improvements
+  * the usual, boring, general improvements
 
 
 More PyPy-powered languages
@@ -231,26 +216,6 @@
 
 - Fast on CPython, super-fast on PyPy
 
-
-cppyy
---
-
-- Interface to C++
-
-- Based on reflection, no need to write wrappers
-
-- PyPy-only, similar to PyCintex for CPython
-
-- Main use case: ROOT
-
-  * http://root.cern.ch
-
-  * a set of OO frameworks with all the functionality needed to handle and
-analyze large amounts of data in a very efficient way
-
-- 3x faster than CPython
-
-
 The future: STM
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Kill and rephrase

2014-07-22 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5367:5ab06d210dc6
Date: 2014-07-22 14:12 +0200
http://bitbucket.org/pypy/extradoc/changeset/5ab06d210dc6/

Log:Kill and rephrase

diff --git a/talk/ep2014/status/talk.pdf b/talk/ep2014/status/talk.pdf
index 
dddab2362990645489cffbd5a4fb451b9b8b7751..61bb368d0398a0f044b40b08e1e24e1e24ad1fd3
GIT binary patch

[cut]

diff --git a/talk/ep2014/status/talk.rst b/talk/ep2014/status/talk.rst
--- a/talk/ep2014/status/talk.rst
+++ b/talk/ep2014/status/talk.rst
@@ -217,16 +217,12 @@
 
 - Software Transactional Memory
 
-- Strategy to solve race conditions
+- Solving the GIL problem
 
-- On-going research project
-
-  * by Armin Rigo and Remi Meier
+- Without bringing the threads and locks mess
 
 - Preliminary versions of pypy-jit-stm available
 
-- Lots of polishing needed
-
 - See talk tomorrow
 
 Contacts, QA
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Commit modified pdf

2014-07-22 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5368:9d5389abdfea
Date: 2014-07-22 14:15 +0200
http://bitbucket.org/pypy/extradoc/changeset/9d5389abdfea/

Log:Commit modified pdf

diff --git a/talk/ep2014/status/talk.pdf b/talk/ep2014/status/talk.pdf
index 
61bb368d0398a0f044b40b08e1e24e1e24ad1fd3..1ad85fa0fe34a4a237ca405797b9dbd596e54ece
GIT binary patch

[cut]

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Rephrase

2014-07-22 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5369:3ffd361a4541
Date: 2014-07-22 14:28 +0200
http://bitbucket.org/pypy/extradoc/changeset/3ffd361a4541/

Log:Rephrase

diff --git a/talk/ep2014/status/talk.pdf b/talk/ep2014/status/talk.pdf
index 
1ad85fa0fe34a4a237ca405797b9dbd596e54ece..aa6078c72592f3c1704408ce9759135c24a70c28
GIT binary patch

[cut]

diff --git a/talk/ep2014/status/talk.rst b/talk/ep2014/status/talk.rst
--- a/talk/ep2014/status/talk.rst
+++ b/talk/ep2014/status/talk.rst
@@ -113,7 +113,7 @@
 
 - STM, 2nd call: 3'000 $ of 80'000 $ (4%)
 
-- thank to all donors!
+- Thanks to all donors!
 
 Commercial support
 --
@@ -166,23 +166,23 @@
 
 - ~7.5x faster than CPython on ARM
 
-- thanks to Raspberry-Pi foundation
+- Thanks to the Raspberry-Pi foundation
 
-- distributed as part of Raspbian OS
+- Distributed as part of Raspbian OS
 
 
 numpy
 -
 
-- as usual, in-progress
+- As usual, in-progress
 
 - 2336 passing tests out of 3265
 
   * http://buildbot.pypy.org/numpy-status/latest.html
 
-- just try it
+- Just try it
 
-- no scipy :-/
+- No scipy :-/
 
 
 py3k
@@ -192,9 +192,9 @@
 
 - 3.3: branch started, in-progress
 
-- some missing optimizations
+- Some missing optimizations
 
-  * getting better
+  * Getting better
 
 
 CFFI
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Add stub for ufunc.outer

2014-01-28 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r68977:d7c223f70bc3
Date: 2014-01-27 21:49 +0100
http://bitbucket.org/pypy/pypy/changeset/d7c223f70bc3/

Log:Add stub for ufunc.outer

diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -254,6 +254,13 @@
 return out
 return res
 
+def descr_outer(self, space, __args__):
+return self._outer(space, __args__)
+
+def _outer(self, space, __args__):
+raise OperationError(space.w_TypeError,
+ space.wrap(outer product only supported for 
binary functions))
+
 class W_Ufunc1(W_Ufunc):
 _immutable_fields_ = [func, bool_result]
 argcount = 1
@@ -432,6 +439,7 @@
 nin = interp_attrproperty(argcount, cls=W_Ufunc),
 
 reduce = interp2app(W_Ufunc.descr_reduce),
+outer = interp2app(W_Ufunc.descr_outer),
 )
 
 
diff --git a/pypy/module/micronumpy/test/test_ufuncs.py 
b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -1052,3 +1052,8 @@
 np.array([0, -1, -3, -6, -10])).all()
 assert (np.divide.accumulate(todivide) ==
 np.array([2., 4., 16.])).all()
+
+def test_outer(self):
+import numpy as np
+from numpypy import absolute
+assert raises(TypeError, np.absolute.outer, [-1, -2])
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: (Hopefully) final modifications

2014-01-27 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5143:326c63faded1
Date: 2014-01-27 17:52 +0100
http://bitbucket.org/pypy/extradoc/changeset/326c63faded1/

Log:(Hopefully) final modifications

diff --git a/talk/fosdem2014/pypy-jit/talk.pdf 
b/talk/fosdem2014/pypy-jit/talk.pdf
new file mode 100644
index 
..78643be7cc20a8371fc7ae6eebf74543936b90f7
GIT binary patch

[cut]

diff --git a/talk/fosdem2014/pypy-jit/talk.rst 
b/talk/fosdem2014/pypy-jit/talk.rst
--- a/talk/fosdem2014/pypy-jit/talk.rst
+++ b/talk/fosdem2014/pypy-jit/talk.rst
@@ -51,6 +51,17 @@
 
 * Produces optimized machine code
 
+RPython
+===
+
+* Statically typed subset of Python
+
+* The RPython compiler automatically generates the JIT from the annotated 
RPython code
+
+* The JIT can be added with just one line of code
+
+* More hints are needed to have an efficient JIT
+
 Tracing JIT
 ===
 
@@ -60,6 +71,8 @@
 
 * Produces a linear trace of execution
 
+* Inlines almost everything
+
 * The trace is then optimized and compiled
 
 Guard
@@ -78,6 +91,15 @@
 
 * After a guard has failed X times, the other path is traced, compiled and 
attached to the trace
 
+Optimizations
+=
+
+* Virtuals
+
+* Virtualizables
+
+* Promotion
+
 Jitviewer
 =
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add my FOSDEM talk

2014-01-25 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5141:1b90c0f4886c
Date: 2014-01-26 01:00 +0100
http://bitbucket.org/pypy/extradoc/changeset/1b90c0f4886c/

Log:Add my FOSDEM talk

diff --git a/talk/fosdem2014/pypy-jit/Makefile 
b/talk/fosdem2014/pypy-jit/Makefile
new file mode 100644
--- /dev/null
+++ b/talk/fosdem2014/pypy-jit/Makefile
@@ -0,0 +1,16 @@
+# you can find rst2beamer.py and inkscapeslide.py here:
+# http://bitbucket.org/antocuni/env/src/619f486c4fad/bin/rst2beamer.py
+# http://bitbucket.org/antocuni/env/src/619f486c4fad/bin/inkscapeslide.py
+
+
+talk.pdf: talk.rst author.latex stylesheet.latex
+   rst2beamer.py --input-encoding=utf8 --output-encoding=utf8 
--stylesheet=stylesheet.latex --documentoptions=14pt talk.rst talk.latex || exit
+   sed 's/\\date{}/\\input{author.latex}/' -i talk.latex || exit
+   #sed 's/\\maketitle/\\input{title.latex}/' -i talk.latex || exit
+   pdflatex talk.latex  || exit
+
+view: talk.pdf
+   evince talk.pdf  /dev/null 21 
+
+xpdf: talk.pdf
+   xpdf talk.pdf 
diff --git a/talk/fosdem2014/pypy-jit/Speed.png 
b/talk/fosdem2014/pypy-jit/Speed.png
new file mode 100644
index 
..796a1ed2ef8f48d701a54242e78694ac16a70762
GIT binary patch

[cut]

diff --git a/talk/fosdem2014/pypy-jit/author.latex 
b/talk/fosdem2014/pypy-jit/author.latex
new file mode 100644
--- /dev/null
+++ b/talk/fosdem2014/pypy-jit/author.latex
@@ -0,0 +1,8 @@
+\definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0}
+
+\title[How PyPy makes your code run fast]{How PyPy makes your code run fast}
+\author[rguillebert]
+{Romain Guillebert}
+
+\institute{FOSDEM}
+\date{February 2nd, 2014}
diff --git a/talk/fosdem2014/pypy-jit/beamerdefs.txt 
b/talk/fosdem2014/pypy-jit/beamerdefs.txt
new file mode 100644
--- /dev/null
+++ b/talk/fosdem2014/pypy-jit/beamerdefs.txt
@@ -0,0 +1,108 @@
+.. colors
+.. ===
+
+.. role:: green
+.. role:: red
+
+
+.. general useful commands
+.. ===
+
+.. |pause| raw:: latex
+
+   \pause
+
+.. |small| raw:: latex
+
+   {\small
+
+.. |end_small| raw:: latex
+
+   }
+
+.. |scriptsize| raw:: latex
+
+   {\scriptsize
+
+.. |end_scriptsize| raw:: latex
+
+   }
+
+.. |strike| raw:: latex
+
+   \sout{
+
+.. closed bracket
+.. ===
+
+.. || raw:: latex
+
+   }
+
+
+.. example block
+.. ===
+
+.. |example| raw:: latex
+
+   \begin{exampleblock}{
+
+
+.. |end_example| raw:: latex
+
+   \end{exampleblock}
+
+
+
+.. alert block
+.. ===
+
+.. |alert| raw:: latex
+
+   \begin{alertblock}{
+
+
+.. |end_alert| raw:: latex
+
+   \end{alertblock}
+
+
+
+.. columns
+.. ===
+
+.. |column1| raw:: latex
+
+   \begin{columns}
+  \begin{column}{0.45\textwidth}
+
+.. |column2| raw:: latex
+
+  \end{column}
+  \begin{column}{0.45\textwidth}
+
+
+.. |end_columns| raw:: latex
+
+  \end{column}
+   \end{columns}
+
+
+
+.. |snake| image:: ../../img/py-web-new.png
+   :scale: 15%
+   
+
+
+.. nested blocks
+.. ===
+
+.. |nested| raw:: latex
+
+   \begin{columns}
+  \begin{column}{0.85\textwidth}
+
+.. |end_nested| raw:: latex
+
+  \end{column}
+   \end{columns}
diff --git a/talk/fosdem2014/pypy-jit/rst2beamer.py 
b/talk/fosdem2014/pypy-jit/rst2beamer.py
new file mode 100755
--- /dev/null
+++ b/talk/fosdem2014/pypy-jit/rst2beamer.py
@@ -0,0 +1,267 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+A docutils script converting restructured text into Beamer-flavoured LaTeX.
+
+Beamer is a LaTeX document class for presentations. Via this script, ReST can
+be used to prepare slides. It can be called::
+
+rst2beamer.py infile.txt  outfile.tex
+
+where ``infile.tex`` contains the produced Beamer LaTeX.
+
+See http:www.agapow.net/programming/python/rst2beamer for more details.
+
+
+# TODO: modifications for handout sections?
+# TOOD: sections and subsections?
+# TODO: enable beamer themes?
+# TODO: convert document metadata to front page fields?
+# TODO: toc-conversion?
+# TODO: fix descriptions
+
+# Unless otherwise stated, created by P-M Agapow on 2007-08-21
+# and open for academic  non-commercial use and modification .
+
+__docformat__ = 'restructuredtext en'
+__author__ = Paul-Michael Agapow aga...@bbsrc.ac.uk
+__version__ = 0.2
+
+
+### IMPORTS ###
+
+import locale
+from docutils.core import publish_cmdline, default_description
+from docutils.writers.latex2e import Writer as Latex2eWriter
+from docutils.writers.latex2e import LaTeXTranslator, DocumentClass
+from docutils import nodes
+
+## Syntax highlighting:
+
+
+.. sourcecode:: python
+
+My code goes here.
+
+
+:copyright: 2007 by Georg Brandl.
+:license: BSD, see LICENSE for more details.
+
+
+from pygments.formatters import HtmlFormatter, LatexFormatter
+
+# The default formatter
+DEFAULT = LatexFormatter()
+
+
+from docutils.parsers.rst

[pypy-commit] extradoc extradoc: Update to the talk

2014-01-25 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5142:ab2f21f5af4a
Date: 2014-01-26 01:34 +0100
http://bitbucket.org/pypy/extradoc/changeset/ab2f21f5af4a/

Log:Update to the talk

diff --git a/talk/fosdem2014/pypy-jit/talk.rst 
b/talk/fosdem2014/pypy-jit/talk.rst
--- a/talk/fosdem2014/pypy-jit/talk.rst
+++ b/talk/fosdem2014/pypy-jit/talk.rst
@@ -31,14 +31,14 @@
 
 * GCC
 
-* You can optimize only on what you know before running the program
+* Can optimize only on what it knows before running the program
 
 Interpreter
 ===
 
 * CPython, PyPy
 
-* Do everything at runtime
+* Executes an abstract representation of the program
 
 * Not very smart
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: More tests

2014-01-22 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r68844:4685b47e9d49
Date: 2014-01-22 17:15 +0100
http://bitbucket.org/pypy/pypy/changeset/4685b47e9d49/

Log:More tests

diff --git a/pypy/module/micronumpy/test/test_subtype.py 
b/pypy/module/micronumpy/test/test_subtype.py
--- a/pypy/module/micronumpy/test/test_subtype.py
+++ b/pypy/module/micronumpy/test/test_subtype.py
@@ -311,6 +311,11 @@
 assert type(x) == with_prepare
 assert x.called_prepare
 raises(TypeError, add, a, b, out=c)
+a = array(1).view(type=with_prepare)
+b = array(1)
+x = add(a, b)
+assert x == 2
+assert x.called_prepare
 
 def test___array_prepare__1arg_scalar(self):
 from numpypy import ndarray, array, log, ones
@@ -368,6 +373,16 @@
 assert x.called_prepare
 raises(TypeError, add, a, b, out=c)
 
+def test_result_is_subtype(self):
+from numpypy import ndarray, add, array
+class subtype(ndarray):
+pass
+
+a = array(10).view(subtype)
+b = 10
+res = add(a, b)
+assert isinstance(res, subtype)
+
 def test__getitem_modifies_shape(self):
 import numpypy as N
 # numpy's matrix class caused an infinite loop
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Call __array_prepare__ in more cases

2014-01-22 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r68845:07b429e67743
Date: 2014-01-22 17:19 +0100
http://bitbucket.org/pypy/pypy/changeset/07b429e67743/

Log:Call __array_prepare__ in more cases

diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -419,15 +419,17 @@
 w_rhs.get_scalar_value().convert_to(space, calc_dtype)
 )
 if isinstance(out, W_NDimArray):
-# TODO: Call __array_prepare__
+# TODO: Array priority
+out = loop.call_prepare(space, w_out, w_out)
+
 if out.is_scalar():
 out.set_scalar_value(arr)
 else:
 out.fill(space, arr)
 else:
-# TODO: Call __array_prepare__
-out = W_NDimArray(Scalar(res_dtype, res_dtype.box(0)))
-out.set_scalar_value(arr)
+# TODO: Array priority
+out = loop.call_prepare(space, w_lhs, arr)
+# XXX: How to set the value on the box since they're immutable 
?
 
 return out
 new_shape = shape_agreement(space, w_lhs.get_shape(), w_rhs)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy resume-refactor: Add the RESUME_PUT_CONST resume resop

2014-01-17 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: resume-refactor
Changeset: r68718:354d632cf82c
Date: 2014-01-17 14:50 +0100
http://bitbucket.org/pypy/pypy/changeset/354d632cf82c/

Log:Add the RESUME_PUT_CONST resume resop

diff --git a/rpython/jit/metainterp/resoperation.py 
b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -473,6 +473,7 @@
 'RESUME_PUT/3', # arguments are as follows - box or position in the 
backend,
 # the frame index (counting from top) and position in the
 # frontend
+'RESUME_PUT_CONST/3',
 'RESUME_NEW/0d',
 'RESUME_NEW_WITH_VTABLE/1',
 'RESUME_NEW_ARRAY/1d',
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy resume-refactor: Backed out changeset 354d632cf82c

2014-01-17 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: resume-refactor
Changeset: r68719:c93364c949d0
Date: 2014-01-17 14:54 +0100
http://bitbucket.org/pypy/pypy/changeset/c93364c949d0/

Log:Backed out changeset 354d632cf82c

diff --git a/rpython/jit/metainterp/resoperation.py 
b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -473,7 +473,6 @@
 'RESUME_PUT/3', # arguments are as follows - box or position in the 
backend,
 # the frame index (counting from top) and position in the
 # frontend
-'RESUME_PUT_CONST/3',
 'RESUME_NEW/0d',
 'RESUME_NEW_WITH_VTABLE/1',
 'RESUME_NEW_ARRAY/1d',
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy resume-refactor: Add missing imports

2014-01-17 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: resume-refactor
Changeset: r68721:6c647ae0fbf8
Date: 2014-01-17 16:00 +0100
http://bitbucket.org/pypy/pypy/changeset/6c647ae0fbf8/

Log:Add missing imports

diff --git a/rpython/jit/metainterp/test/test_resume.py 
b/rpython/jit/metainterp/test/test_resume.py
--- a/rpython/jit/metainterp/test/test_resume.py
+++ b/rpython/jit/metainterp/test/test_resume.py
@@ -11,6 +11,7 @@
 from rpython.jit.metainterp.optimizeopt.test.test_util import LLtypeMixin
 from rpython.jit.metainterp import executor
 from rpython.jit.codewriter import heaptracker, longlong
+from rpython.jit.resume.rescode import TAGBOX, TAGCONST, TAGINT, TAGVIRTUAL
 
 class Storage:
 rd_frame_info_list = None
@@ -24,14 +25,14 @@
 class FakeOptimizer(object):
 def __init__(self, values):
 self.values = values
-
+
 def getvalue(self, box):
 try:
 value = self.values[box]
 except KeyError:
 value = self.values[box] = OptValue(box)
 return value
-
+
 
 def test_tag():
 assert tag(3, 1) == rffi.r_short(32|1)
@@ -81,7 +82,7 @@
 def newframe(self, jitcode):
 frame = FakeFrame(jitcode, -1)
 self.framestack.append(frame)
-return frame
+return frame
 
 def execute_and_record(self, opnum, descr, *argboxes):
 resbox = executor.execute(self.cpu, None, opnum, descr, *argboxes)
@@ -255,7 +256,7 @@
 
 class FakeResumeDataReader(AbstractResumeDataReader):
 VirtualCache = get_VirtualCache_class('Fake')
-
+
 def allocate_with_vtable(self, known_class):
 return FakeBuiltObject(vtable=known_class)
 def allocate_struct(self, typedescr):
@@ -398,7 +399,7 @@
 
 def setup_resume_at_op(self, pc, exception_target, env):
 self.__init__(self.jitcode, pc, exception_target, *env)
-
+
 def __eq__(self, other):
 return self.__dict__ == other.__dict__
 def __ne__(self, other):
@@ -516,7 +517,7 @@
 def test_rebuild_from_resumedata():
 py.test.skip(XXX rewrite)
 b1, b2, b3 = [BoxInt(), BoxPtr(), BoxInt()]
-c1, c2, c3 = [ConstInt(1), ConstInt(2), ConstInt(3)]
+c1, c2, c3 = [ConstInt(1), ConstInt(2), ConstInt(3)]
 storage = Storage()
 fs = [FakeFrame(code0, 0, b1, c1, b2),
   FakeFrame(code1, 3, b3, c2, b1),
@@ -540,7 +541,7 @@
 def test_rebuild_from_resumedata_with_virtualizable():
 py.test.skip(XXX rewrite)
 b1, b2, b3, b4 = [BoxInt(), BoxPtr(), BoxInt(), BoxPtr()]
-c1, c2, c3 = [ConstInt(1), ConstInt(2), ConstInt(3)]
+c1, c2, c3 = [ConstInt(1), ConstInt(2), ConstInt(3)]
 storage = Storage()
 fs = [FakeFrame(code0, 0, b1, c1, b2),
   FakeFrame(code1, 3, b3, c2, b1),
@@ -565,7 +566,7 @@
 def test_rebuild_from_resumedata_two_guards():
 py.test.skip(XXX rewrite)
 b1, b2, b3, b4 = [BoxInt(), BoxPtr(), BoxInt(), BoxInt()]
-c1, c2, c3 = [ConstInt(1), ConstInt(2), ConstInt(3)]
+c1, c2, c3 = [ConstInt(1), ConstInt(2), ConstInt(3)]
 storage = Storage()
 fs = [FakeFrame(code0, 0, b1, c1, b2),
   FakeFrame(code1, 3, b3, c2, b1),
@@ -574,7 +575,7 @@
 storage2 = Storage()
 fs = fs[:-1] + [FakeFrame(code2, 10, c3, b2, b4)]
 capture_resumedata(fs, None, [], storage2)
-
+
 memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
 modifier = ResumeDataVirtualAdder(storage, memo)
 liveboxes = modifier.finish(FakeOptimizer({}))
@@ -625,7 +626,7 @@
 
 def test_rebuild_from_resumedata_two_guards_w_virtuals():
 py.test.skip(XXX rewrite)
-
+
 b1, b2, b3, b4, b5 = [BoxInt(), BoxPtr(), BoxInt(), BoxInt(), BoxInt()]
 c1, c2, c3, c4 = [ConstInt(1), ConstInt(2), ConstInt(3),
   LLtypeMixin.nodebox.constbox()]
@@ -637,7 +638,7 @@
 storage2 = Storage()
 fs = fs[:-1] + [FakeFrame(code2, 10, c3, b2, b4)]
 capture_resumedata(fs, None, [], storage2)
-
+
 memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
 values = {b2: virtual_value(b2, b5, c4)}
 modifier = ResumeDataVirtualAdder(storage, memo)
@@ -648,12 +649,12 @@
 
 b6 = BoxPtr()
 v6 = virtual_value(b6, c2, None)
-v6.setfield(LLtypeMixin.nextdescr, v6)
+v6.setfield(LLtypeMixin.nextdescr, v6)
 values = {b2: virtual_value(b2, b4, v6), b6: v6}
 memo.clear_box_virtual_numbers()
 modifier = ResumeDataVirtualAdder(storage2, memo)
 liveboxes2 = modifier.finish(FakeOptimizer(values))
-assert len(storage2.rd_virtuals) == 2
+assert len(storage2.rd_virtuals) == 2
 assert storage2.rd_virtuals[0].fieldnums == [tag(len(liveboxes2)-1, 
TAGBOX),
  tag(-1, TAGVIRTUAL)]
 assert storage2.rd_virtuals[1].fieldnums == [tag(2, TAGINT),
@@ -684,7 +685,7 @@
 fs2 = [FakeFrame(code0, 0, b1t, c1, b2t),
FakeFrame(code1, 3, b3t, c2, b1t),
FakeFrame(code2, 10, c3, b2t, b4t)]
-assert metainterp.framestack == fs2

[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Change the way ufuncs work on scalar to make it possible to call __array_prepare__

2014-01-16 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r68693:a9b32d23096f
Date: 2014-01-16 11:00 +0100
http://bitbucket.org/pypy/pypy/changeset/a9b32d23096f/

Log:Change the way ufuncs work on scalar to make it possible to call
__array_prepare__

diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -10,6 +10,7 @@
 from pypy.module.micronumpy.strides import shape_agreement
 from pypy.module.micronumpy.base import convert_to_array, W_NDimArray
 from pypy.module.micronumpy.constants import *
+from pypy.module.micronumpy.arrayimpl.scalar import Scalar
 
 def done_if_true(dtype, val):
 return dtype.itemtype.bool(val)
@@ -383,8 +384,8 @@
 w_ldtype = w_rdtype
 
 if (self.int_only and (not w_ldtype.is_int_type() or not 
w_rdtype.is_int_type()) or
-not self.allow_bool and (w_ldtype.is_bool_type() or 
w_rdtype.is_bool_type()) or
-not self.allow_complex and (w_ldtype.is_complex_type() or 
w_rdtype.is_complex_type())):
+not self.allow_bool and (w_ldtype.is_bool_type() or 
w_rdtype.is_bool_type()) or
+not self.allow_complex and (w_ldtype.is_complex_type() or 
w_rdtype.is_complex_type())):
 raise OperationError(space.w_TypeError, space.wrap(Unsupported 
types))
 
 calc_dtype = find_binop_result_dtype(space,
@@ -418,12 +419,16 @@
 w_rhs.get_scalar_value().convert_to(space, calc_dtype)
 )
 if isinstance(out, W_NDimArray):
+# TODO: Call __array_prepare__
 if out.is_scalar():
 out.set_scalar_value(arr)
 else:
 out.fill(space, arr)
 else:
-out = arr
+# TODO: Call __array_prepare__
+out = W_NDimArray(Scalar(res_dtype, res_dtype.box(0)))
+out.set_scalar_value(arr)
+
 return out
 new_shape = shape_agreement(space, w_lhs.get_shape(), w_rhs)
 new_shape = shape_agreement(space, new_shape, out, 
broadcast_down=False)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add Christian Clauss

2013-12-04 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5113:14ae32e9371f
Date: 2013-12-04 18:27 +0100
http://bitbucket.org/pypy/extradoc/changeset/14ae32e9371f/

Log:Add Christian Clauss

diff --git a/sprintinfo/leysin-winter-2014/people.txt 
b/sprintinfo/leysin-winter-2014/people.txt
--- a/sprintinfo/leysin-winter-2014/people.txt
+++ b/sprintinfo/leysin-winter-2014/people.txt
@@ -12,6 +12,7 @@
  == ===
 Armin Rigo  private
 Romain Guillebert11-19  Ermina
+Christian Clauss 11-12  18-19  I live nearby
  == ===
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add myself

2013-11-30 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5112:154de39968e1
Date: 2013-11-30 15:40 +0100
http://bitbucket.org/pypy/extradoc/changeset/154de39968e1/

Log:Add myself

diff --git a/sprintinfo/leysin-winter-2014/people.txt 
b/sprintinfo/leysin-winter-2014/people.txt
--- a/sprintinfo/leysin-winter-2014/people.txt
+++ b/sprintinfo/leysin-winter-2014/people.txt
@@ -11,6 +11,7 @@
 Name  Arrive/Depart Accomodation 
  == ===
 Armin Rigo  private
+Romain Guillebert11-19  Ermina
  == ===
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Forgot to solve this merge conflict

2013-11-19 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r68247:0559ff165dad
Date: 2013-11-19 20:10 +0100
http://bitbucket.org/pypy/pypy/changeset/0559ff165dad/

Log:Forgot to solve this merge conflict

diff --git a/pypy/module/micronumpy/interp_boxes.py 
b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -313,9 +313,6 @@
 self.w_flags = W_FlagsObject(self)
 return self.w_flags
 
-def descr_dtype(self, space):
-return self._get_dtype(space)
-
 class W_BoolBox(W_GenericBox, PrimitiveBox):
 descr__new__, _get_dtype, descr_reduce = new_dtype_getter(bool)
 
@@ -567,9 +564,6 @@
 conjugate = interp2app(W_GenericBox.descr_conjugate),
 astype = interp2app(W_GenericBox.descr_astype),
 view = interp2app(W_GenericBox.descr_view),
- local
-dtype = GetSetProperty(W_GenericBox.descr_dtype)
-===
 squeeze = interp2app(W_GenericBox.descr_self),
 copy = interp2app(W_GenericBox.descr_copy),
 
@@ -582,7 +576,6 @@
 ndim = GetSetProperty(W_GenericBox.descr_get_ndim),
 T = GetSetProperty(W_GenericBox.descr_self),
 flags = GetSetProperty(W_GenericBox.descr_get_flags),
- other
 )
 
 W_BoolBox.typedef = TypeDef(bool_, W_GenericBox.typedef,
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: sum doesn't exist in numpypy

2013-11-19 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r68248:b5c80215f7e5
Date: 2013-11-19 21:08 +0100
http://bitbucket.org/pypy/pypy/changeset/b5c80215f7e5/

Log:sum doesn't exist in numpypy

diff --git a/pypy/module/micronumpy/test/test_subtype.py 
b/pypy/module/micronumpy/test/test_subtype.py
--- a/pypy/module/micronumpy/test/test_subtype.py
+++ b/pypy/module/micronumpy/test/test_subtype.py
@@ -374,7 +374,7 @@
 raises(TypeError, log, a, out=c)
 
 def test___array_prepare__reduce(self):
-from numpypy import ndarray, array, sum, ones, add
+from numpypy import ndarray, array, ones, add
 class with_prepare(ndarray):
 def __array_prepare__(self, arr, context):
 x = array(arr).view(type=with_prepare)
@@ -382,7 +382,7 @@
 print 'called_prepare',arr
 return x
 a = ones(2).view(type=with_prepare)
-x = sum(a)
+x = a.sum()
 assert type(x) == with_prepare
 assert x.shape == ()
 # reduce functions do not call prepare, is this a numpy 'feature'?
@@ -391,6 +391,6 @@
 assert type(x) == with_prepare
 assert not getattr(x, 'called_prepare',False)
 a = ones((2,3)).view(type=with_prepare)
-x = sum(a, axis=0)
+x = a.sum(axis=0)
 assert type(x) == with_prepare
 assert not getattr(x, 'called_prepare',False)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Revert Ufunc{1, 2}.call

2013-11-18 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r68214:d18c4175125e
Date: 2013-11-18 17:39 +0100
http://bitbucket.org/pypy/pypy/changeset/d18c4175125e/

Log:Revert Ufunc{1,2}.call

diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -343,17 +343,15 @@
   w_obj.get_scalar_value().convert_to(calc_dtype))
 if out is None:
 return w_val
-if isinstance(out, W_NDimArray):
-if out.is_scalar():
-out.set_scalar_value(w_val)
-else:
-out.fill(res_dtype.coerce(space, w_val))
-return self.call_prepare(space, out, w_obj, w_val)
+if out.is_scalar():
+out.set_scalar_value(w_val)
+else:
+out.fill(res_dtype.coerce(space, w_val))
+return out
 shape = shape_agreement(space, w_obj.get_shape(), out,
 broadcast_down=False)
-w_result = loop.call1(space, shape, self.func, calc_dtype, res_dtype,
+return loop.call1(space, shape, self.func, calc_dtype, res_dtype,
   w_obj, out)
-return self.call_prepare(space, out, w_obj, w_result)
 
 
 class W_Ufunc2(W_Ufunc):
@@ -423,11 +421,11 @@
 promote_bools=self.promote_bools)
 if space.is_none(w_out):
 out = None
-#elif not isinstance(w_out, W_NDimArray):
-#raise OperationError(space.w_TypeError, space.wrap(
-#'output must be an array'))
+elif not isinstance(w_out, W_NDimArray):
+raise OperationError(space.w_TypeError, space.wrap(
+'output must be an array'))
 else:
-out = convert_to_array(space, w_out)
+out = w_out
 calc_dtype = out.get_dtype()
 if self.comparison_func:
 res_dtype = interp_dtype.get_dtype_cache(space).w_booldtype
@@ -443,15 +441,14 @@
 out.set_scalar_value(arr)
 else:
 out.fill(arr)
-arr = out
-# XXX handle array_priority
-return self.call_prepare(space, out, w_lhs, arr)
+else:
+out = arr
+return out
 new_shape = shape_agreement(space, w_lhs.get_shape(), w_rhs)
 new_shape = shape_agreement(space, new_shape, out, 
broadcast_down=False)
-w_result = loop.call2(space, new_shape, self.func, calc_dtype,
+return loop.call2(space, new_shape, self.func, calc_dtype,
   res_dtype, w_lhs, w_rhs, out)
-# XXX handle array_priority
-return self.call_prepare(space, out, w_lhs, w_result)
+
 
 W_Ufunc.typedef = TypeDef(ufunc,
 __module__ = numpypy,
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Move call_prepare to loop.py

2013-11-18 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r68215:145ff824d697
Date: 2013-11-18 17:42 +0100
http://bitbucket.org/pypy/pypy/changeset/145ff824d697/

Log:Move call_prepare to loop.py

diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -256,38 +256,6 @@
 return out
 return res
 
-def call_prepare(self, space, w_out, w_obj, w_result):
-if isinstance(w_out, W_NDimArray):
-w_array = space.lookup(w_out, __array_prepare__)
-w_caller = w_out
-else:
-w_array = space.lookup(w_obj, __array_prepare__)
-w_caller = w_obj
-if w_array:
-w_retVal = space.get_and_call_function(w_array, w_caller, 
w_result, None)
-if not isinstance(w_retVal, W_NDimArray) and \
-   not isinstance(w_retVal, interp_boxes.Box):
-raise OperationError(space.w_ValueError,
-space.wrap( __array_prepare__ must return an 
-ndarray or subclass thereof))
-if isinstance(w_result, interp_boxes.Box) or \
-w_result.is_scalar():
-if not isinstance(w_retVal, interp_boxes.Box) and not 
w_retVal.is_scalar():
-raise OperationError(space.w_TypeError,
-space.wrap( __array_prepare__ must return an 
-ndarray or subclass thereof which is 
-otherwise identical to its input))
-elif w_result.get_shape() != w_retVal.get_shape() or \
-   w_result.implementation.get_strides() != \
-w_retVal.implementation.get_strides():
-raise OperationError(space.w_TypeError,
-space.wrap( __array_prepare__ must return an 
-ndarray or subclass thereof which is 
-otherwise identical to its input))
-return w_retVal
-return w_result
-
-
 class W_Ufunc1(W_Ufunc):
 _immutable_fields_ = [func, bool_result]
 argcount = 1
diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -19,6 +19,37 @@
  reds = ['shape', 'w_lhs', 'w_rhs', 'out',
  'left_iter', 'right_iter', 'out_iter'])
 
+def call_prepare(self, space, w_out, w_obj, w_result):
+if isinstance(w_out, W_NDimArray):
+w_array = space.lookup(w_out, __array_prepare__)
+w_caller = w_out
+else:
+w_array = space.lookup(w_obj, __array_prepare__)
+w_caller = w_obj
+if w_array:
+w_retVal = space.get_and_call_function(w_array, w_caller, w_result, 
None)
+if not isinstance(w_retVal, W_NDimArray) and \
+not isinstance(w_retVal, interp_boxes.Box):
+raise OperationError(space.w_ValueError,
+space.wrap( __array_prepare__ must return an 
+ndarray or subclass thereof))
+if isinstance(w_result, interp_boxes.Box) or \
+w_result.is_scalar():
+if not isinstance(w_retVal, interp_boxes.Box) and not 
w_retVal.is_scalar():
+raise OperationError(space.w_TypeError,
+space.wrap( __array_prepare__ must return an 
+ndarray or subclass thereof which is 
+otherwise identical to its input))
+elif w_result.get_shape() != w_retVal.get_shape() or \
+w_result.implementation.get_strides() != \
+w_retVal.implementation.get_strides():
+raise OperationError(space.w_TypeError,
+space.wrap( __array_prepare__ must return an 
+ndarray or subclass thereof which is 
+otherwise identical to its input))
+return w_retVal
+return w_result
+
 def call2(space, shape, func, calc_dtype, res_dtype, w_lhs, w_rhs, out):
 # handle array_priority
 # w_lhs and w_rhs could be of different ndarray subtypes. Numpy does:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Remove useless code

2013-11-18 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r68217:5848d1c58c12
Date: 2013-11-18 18:30 +0100
http://bitbucket.org/pypy/pypy/changeset/5848d1c58c12/

Log:Remove useless code

diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -173,7 +173,6 @@
 shapelen = len(obj_shape)
 axis = unwrap_axis_arg(space, shapelen, w_axis)
 assert axis = 0
-size = obj.get_size()
 dtype = interp_dtype.decode_w_dtype(space, dtype)
 if dtype is None:
 if self.comparison_func:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Implement __array_prepare__ for non-scalar

2013-11-18 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r68218:25afd81e613b
Date: 2013-11-18 18:31 +0100
http://bitbucket.org/pypy/pypy/changeset/25afd81e613b/

Log:Implement __array_prepare__ for non-scalar

diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -12,22 +12,12 @@
 from pypy.module.micronumpy.iter import PureShapeIterator
 from pypy.module.micronumpy import constants
 from pypy.module.micronumpy.support import int_w
+from pypy.module.micronumpy import interp_boxes
 
-call2_driver = jit.JitDriver(name='numpy_call2',
- greens = ['shapelen', 'func', 'calc_dtype',
-   'res_dtype'],
- reds = ['shape', 'w_lhs', 'w_rhs', 'out',
- 'left_iter', 'right_iter', 'out_iter'])
-
-def call_prepare(self, space, w_out, w_obj, w_result):
-if isinstance(w_out, W_NDimArray):
-w_array = space.lookup(w_out, __array_prepare__)
-w_caller = w_out
-else:
-w_array = space.lookup(w_obj, __array_prepare__)
-w_caller = w_obj
+def call_prepare(space, w_obj, w_result):
+w_array = space.lookup(w_obj, __array_prepare__)
 if w_array:
-w_retVal = space.get_and_call_function(w_array, w_caller, w_result, 
None)
+w_retVal = space.get_and_call_function(w_array, w_obj, w_result, None)
 if not isinstance(w_retVal, W_NDimArray) and \
 not isinstance(w_retVal, interp_boxes.Box):
 raise OperationError(space.w_ValueError,
@@ -50,6 +40,11 @@
 return w_retVal
 return w_result
 
+call2_driver = jit.JitDriver(name='numpy_call2',
+ greens = ['shapelen', 'func', 'calc_dtype',
+   'res_dtype'],
+ reds = ['shape', 'w_lhs', 'w_rhs', 'out',
+ 'left_iter', 'right_iter', 'out_iter'])
 def call2(space, shape, func, calc_dtype, res_dtype, w_lhs, w_rhs, out):
 # handle array_priority
 # w_lhs and w_rhs could be of different ndarray subtypes. Numpy does:
@@ -78,6 +73,10 @@
 if out is None:
 out = W_NDimArray.from_shape(space, shape, res_dtype,
  w_instance=lhs_for_subtype)
+out = call_prepare(space, w_lhs, out)
+else:
+out = call_prepare(space, out, out)
+
 left_iter = w_lhs.create_iter(shape)
 right_iter = w_rhs.create_iter(shape)
 out_iter = out.create_iter(shape)
@@ -107,6 +106,9 @@
 def call1(space, shape, func, calc_dtype, res_dtype, w_obj, out):
 if out is None:
 out = W_NDimArray.from_shape(space, shape, res_dtype, w_instance=w_obj)
+out = call_prepare(space, w_obj, out)
+else:
+out = call_prepare(space, out, out)
 obj_iter = w_obj.create_iter(shape)
 out_iter = out.create_iter(shape)
 shapelen = len(shape)
diff --git a/pypy/module/micronumpy/test/test_subtype.py 
b/pypy/module/micronumpy/test/test_subtype.py
--- a/pypy/module/micronumpy/test/test_subtype.py
+++ b/pypy/module/micronumpy/test/test_subtype.py
@@ -260,7 +260,7 @@
 assert type(x) == ndarray
 assert a.called_wrap
 
-def test___array_prepare__2arg(self):
+def test___array_prepare__2arg_scalar(self):
 from numpypy import ndarray, array, add, ones
 class with_prepare(ndarray):
 def __array_prepare__(self, arr, context):
@@ -287,7 +287,7 @@
 assert x.called_prepare
 raises(TypeError, add, a, b, out=c)
 
-def test___array_prepare__1arg(self):
+def test___array_prepare__1arg_scalar(self):
 from numpypy import ndarray, array, log, ones
 class with_prepare(ndarray):
 def __array_prepare__(self, arr, context):
@@ -316,6 +316,61 @@
 assert x.called_prepare
 raises(TypeError, log, a, out=c)
 
+def test___array_prepare__2arg_array(self):
+from numpypy import ndarray, array, add, ones
+class with_prepare(ndarray):
+def __array_prepare__(self, arr, context):
+retVal = array(arr).view(type=with_prepare)
+retVal.called_prepare = True
+return retVal
+class with_prepare_fail(ndarray):
+called_prepare = False
+def __array_prepare__(self, arr, context):
+return array(arr[0]).view(type=with_prepare)
+a = array([1])
+b = array([1]).view(type=with_prepare)
+x = add(a, a, out=b)
+assert x == 2
+assert type(x) == with_prepare
+assert x.called_prepare
+b.called_prepare = False
+a = ones((3, 2)).view(type=with_prepare)
+b = ones((3, 2))
+c = ones((3, 2)).view(type=with_prepare_fail)
+x = add(a, b, out=a)
+assert (x == 2).all()
+assert 

[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Remove a bad assertion

2013-10-22 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r67516:b91225187b3a
Date: 2013-10-22 17:34 +0200
http://bitbucket.org/pypy/pypy/changeset/b91225187b3a/

Log:Remove a bad assertion

diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -240,7 +240,6 @@
 return res
 
 def call_prepare(self, space, w_out, w_obj, w_result):
-assert isinstance(w_result, W_NDimArray)
 if isinstance(w_out, W_NDimArray):
 w_array = space.lookup(w_out, __array_prepare__)
 w_caller = w_out
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Add Box.dtype

2013-10-22 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r67518:7d623144a86e
Date: 2013-10-22 18:01 +0200
http://bitbucket.org/pypy/pypy/changeset/7d623144a86e/

Log:Add Box.dtype

diff --git a/pypy/module/micronumpy/interp_boxes.py 
b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -251,6 +251,9 @@
 raise OperationError(space.w_NotImplementedError, space.wrap(
 view not implelemnted yet))
 
+def descr_dtype(self, space):
+return self._get_dtype(space)
+
 class W_BoolBox(W_GenericBox, PrimitiveBox):
 descr__new__, _get_dtype, descr_reduce = new_dtype_getter(bool)
 
@@ -524,6 +527,7 @@
 round = interp2app(W_GenericBox.descr_round),
 conjugate = interp2app(W_GenericBox.descr_conjugate),
 view = interp2app(W_GenericBox.descr_view),
+dtype = GetSetProperty(W_GenericBox.descr_dtype)
 )
 
 W_BoolBox.typedef = TypeDef(bool_, W_GenericBox.typedef,
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Fix typo

2013-10-17 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r67463:4b9adb9cb0db
Date: 2013-10-17 18:21 +0200
http://bitbucket.org/pypy/pypy/changeset/4b9adb9cb0db/

Log:Fix typo

diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -357,7 +357,7 @@
 elif name == 'logical_or':
 self.done_func = done_if_true
 else:
-self.done_func = Non
+self.done_func = None
 
 def are_common_types(self, dtype1, dtype2):
 if dtype1.is_complex_type() and dtype2.is_complex_type():
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add my talk at paris.py, in French :)

2013-10-16 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r5093:c6b907f56bb2
Date: 2013-10-16 11:02 +0200
http://bitbucket.org/pypy/extradoc/changeset/c6b907f56bb2/

Log:Add my talk at paris.py, in French :)

diff --git a/talk/paris.py-3/Makefile b/talk/paris.py-3/Makefile
new file mode 100644
--- /dev/null
+++ b/talk/paris.py-3/Makefile
@@ -0,0 +1,16 @@
+# you can find rst2beamer.py and inkscapeslide.py here:
+# http://bitbucket.org/antocuni/env/src/619f486c4fad/bin/rst2beamer.py
+# http://bitbucket.org/antocuni/env/src/619f486c4fad/bin/inkscapeslide.py
+
+
+talk.pdf: talk.rst author.latex stylesheet.latex
+   rst2beamer.py --input-encoding=utf8 --output-encoding=utf8 
--stylesheet=stylesheet.latex --documentoptions=14pt talk.rst talk.latex || exit
+   sed 's/\\date{}/\\input{author.latex}/' -i talk.latex || exit
+   #sed 's/\\maketitle/\\input{title.latex}/' -i talk.latex || exit
+   pdflatex talk.latex  || exit
+
+view: talk.pdf
+   evince talk.pdf  /dev/null 21 
+
+xpdf: talk.pdf
+   xpdf talk.pdf 
diff --git a/talk/paris.py-3/Speed.png b/talk/paris.py-3/Speed.png
new file mode 100644
index 
..796a1ed2ef8f48d701a54242e78694ac16a70762
GIT binary patch

[cut]

diff --git a/talk/paris.py-3/Time.png b/talk/paris.py-3/Time.png
new file mode 100644
index 
..3618f1e4a4f55d3604a686051fce2f7fe31a3bda
GIT binary patch

[cut]

diff --git a/talk/paris.py-3/author.latex b/talk/paris.py-3/author.latex
new file mode 100644
--- /dev/null
+++ b/talk/paris.py-3/author.latex
@@ -0,0 +1,8 @@
+\definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0}
+
+\title[PyPy : l'impl#233;mentation la plus rapide de Python]{PyPy : 
l'impl#233;mentation la plus rapide de Python}
+\author[rguillebert]
+{Romain Guillebert}
+
+\institute{Paris.py}
+\date{15 octobre 2013}
diff --git a/talk/paris.py-3/beamerdefs.txt b/talk/paris.py-3/beamerdefs.txt
new file mode 100644
--- /dev/null
+++ b/talk/paris.py-3/beamerdefs.txt
@@ -0,0 +1,108 @@
+.. colors
+.. ===
+
+.. role:: green
+.. role:: red
+
+
+.. general useful commands
+.. ===
+
+.. |pause| raw:: latex
+
+   \pause
+
+.. |small| raw:: latex
+
+   {\small
+
+.. |end_small| raw:: latex
+
+   }
+
+.. |scriptsize| raw:: latex
+
+   {\scriptsize
+
+.. |end_scriptsize| raw:: latex
+
+   }
+
+.. |strike| raw:: latex
+
+   \sout{
+
+.. closed bracket
+.. ===
+
+.. || raw:: latex
+
+   }
+
+
+.. example block
+.. ===
+
+.. |example| raw:: latex
+
+   \begin{exampleblock}{
+
+
+.. |end_example| raw:: latex
+
+   \end{exampleblock}
+
+
+
+.. alert block
+.. ===
+
+.. |alert| raw:: latex
+
+   \begin{alertblock}{
+
+
+.. |end_alert| raw:: latex
+
+   \end{alertblock}
+
+
+
+.. columns
+.. ===
+
+.. |column1| raw:: latex
+
+   \begin{columns}
+  \begin{column}{0.45\textwidth}
+
+.. |column2| raw:: latex
+
+  \end{column}
+  \begin{column}{0.45\textwidth}
+
+
+.. |end_columns| raw:: latex
+
+  \end{column}
+   \end{columns}
+
+
+
+.. |snake| image:: ../../img/py-web-new.png
+   :scale: 15%
+   
+
+
+.. nested blocks
+.. ===
+
+.. |nested| raw:: latex
+
+   \begin{columns}
+  \begin{column}{0.85\textwidth}
+
+.. |end_nested| raw:: latex
+
+  \end{column}
+   \end{columns}
diff --git a/talk/paris.py-3/stylesheet.latex b/talk/paris.py-3/stylesheet.latex
new file mode 100644
--- /dev/null
+++ b/talk/paris.py-3/stylesheet.latex
@@ -0,0 +1,11 @@
+\usetheme{Boadilla}
+\usecolortheme{whale}
+\setbeamercovered{transparent}
+\setbeamertemplate{navigation symbols}{}
+
+\definecolor{darkgreen}{rgb}{0, 0.5, 0.0}
+\newcommand{\docutilsrolegreen}[1]{\color{darkgreen}#1\normalcolor}
+\newcommand{\docutilsrolered}[1]{\color{red}#1\normalcolor}
+
+\newcommand{\green}[1]{\color{darkgreen}#1\normalcolor}
+\newcommand{\red}[1]{\color{red}#1\normalcolor}
diff --git a/talk/paris.py-3/talk.pdf b/talk/paris.py-3/talk.pdf
new file mode 100644
index 
..70e6beb3cd10de4a2fa5cadc8402aafb095efad0
GIT binary patch

[cut]

diff --git a/talk/paris.py-3/talk.rst b/talk/paris.py-3/talk.rst
new file mode 100644
--- /dev/null
+++ b/talk/paris.py-3/talk.rst
@@ -0,0 +1,126 @@
+.. include:: beamerdefs.txt
+
+
+PyPy : l'impl#233;mentation la plus rapide de Python
+
+
+Terminologie
+
+
+* Python
+
+* CPython
+
+* PyPy
+
+* RPython
+
+Introduction
+
+
+* PyPy est un interpreteur Python #233;crit en RPython qui vise #224; 
#234;tre le plus rapide possible
+
+* Vise #224; ex#233;cuter n'importe quel code Python
+
+RPython
+---
+
+* Langage/Framework pour #233;crire des machines virtuelles
+
+* Sous-ensemble de Python
+
+* Vivement d#233;conseill#233; pour d'autres

[pypy-commit] pypy default: Fix pypy issue 1598

2013-10-08 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r67202:2e8639dfd82e
Date: 2013-10-08 14:50 +0200
http://bitbucket.org/pypy/pypy/changeset/2e8639dfd82e/

Log:Fix pypy issue 1598

diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -319,6 +319,15 @@
 else:
 self.done_func = None
 
+def are_common_types(self, dtype1, dtype2):
+if dtype1.is_complex_type() and dtype2.is_complex_type():
+return True
+elif not (dtype1.is_complex_type() or dtype2.is_complex_type()) and \
+(dtype1.is_int_type() and dtype2.is_int_type() or 
dtype1.is_float_type() and dtype2.is_float_type()) and \
+not (dtype1.is_bool_type() or dtype2.is_bool_type()):
+return True
+return False
+
 @jit.unroll_safe
 def call(self, space, args_w):
 if len(args_w)  2:
@@ -339,6 +348,12 @@
  'unsupported operand dtypes %s and %s for %s' % \
  (w_rdtype.get_name(), w_ldtype.get_name(),
   self.name)))
+
+if self.are_common_types(w_ldtype, w_rdtype):
+if not w_lhs.is_scalar() and w_rhs.is_scalar():
+w_rdtype = w_ldtype
+elif w_lhs.is_scalar() and not w_rhs.is_scalar():
+w_ldtype = w_rdtype
 calc_dtype = find_binop_result_dtype(space,
 w_ldtype, w_rdtype,
 int_only=self.int_only,
diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -2971,6 +2971,11 @@
 dtype=[('bg', 'i8'), ('fg', 'i8'), ('char', 'S1')])
 assert c[0][0][char] == 'a'
 
+def test_scalar_coercion(self):
+import numpypy as np
+a = np.array([1,2,3], dtype=np.int16)
+assert (a * 2).dtype == np.int16
+
 class AppTestPyPy(BaseNumpyAppTest):
 def setup_class(cls):
 if option.runappdirect and '__pypy__' not in sys.builtin_module_names:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Add issubdtype

2013-10-08 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r67218:8f6cfebce395
Date: 2013-10-08 17:06 +0200
http://bitbucket.org/pypy/pypy/changeset/8f6cfebce395/

Log:Add issubdtype

diff --git a/lib_pypy/numpypy/core/numerictypes.py 
b/lib_pypy/numpypy/core/numerictypes.py
--- a/lib_pypy/numpypy/core/numerictypes.py
+++ b/lib_pypy/numpypy/core/numerictypes.py
@@ -1,1 +1,75 @@
 from _numpypy.numerictypes import *
+import numpypy
+
+def issubclass_(arg1, arg2):
+
+Determine if a class is a subclass of a second class.
+
+`issubclass_` is equivalent to the Python built-in ``issubclass``,
+except that it returns False instead of raising a TypeError is one
+of the arguments is not a class.
+
+Parameters
+--
+arg1 : class
+Input class. True is returned if `arg1` is a subclass of `arg2`.
+arg2 : class or tuple of classes.
+Input class. If a tuple of classes, True is returned if `arg1` is a
+subclass of any of the tuple elements.
+
+Returns
+---
+out : bool
+Whether `arg1` is a subclass of `arg2` or not.
+
+See Also
+
+issubsctype, issubdtype, issctype
+
+Examples
+
+ np.issubclass_(np.int32, np.int)
+True
+ np.issubclass_(np.int32, np.float)
+False
+
+
+try:
+return issubclass(arg1, arg2)
+except TypeError:
+return False
+
+def issubdtype(arg1, arg2):
+
+Returns True if first argument is a typecode lower/equal in type hierarchy.
+
+Parameters
+--
+arg1, arg2 : dtype_like
+dtype or string representing a typecode.
+
+Returns
+---
+out : bool
+
+See Also
+
+issubsctype, issubclass_
+numpy.core.numerictypes : Overview of numpy type hierarchy.
+
+Examples
+
+ np.issubdtype('S1', str)
+True
+ np.issubdtype(np.float64, np.float32)
+False
+
+
+if issubclass_(arg2, generic):
+return issubclass(numpypy.dtype(arg1).type, arg2)
+mro = numpypy.dtype(arg2).type.mro()
+if len(mro)  1:
+val = mro[1]
+else:
+val = mro[0]
+return issubclass(numpypy.dtype(arg1).type, val)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix PyPy issue 1589

2013-10-04 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r67153:9e583c8e7b41
Date: 2013-10-04 21:24 +0200
http://bitbucket.org/pypy/pypy/changeset/9e583c8e7b41/

Log:Fix PyPy issue 1589

diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -2965,6 +2965,12 @@
 
 assert len(list(a[0])) == 2
 
+def test_issue_1589(self):
+import numpypy as numpy
+c = numpy.array([[(1, 2, 'a'), (3, 4, 'b')], [(5, 6, 'c'), (7, 8, 
'd')]],
+dtype=[('bg', 'i8'), ('fg', 'i8'), ('char', 'S1')])
+assert c[0][0][char] == 'a'
+
 class AppTestPyPy(BaseNumpyAppTest):
 def setup_class(cls):
 if option.runappdirect and '__pypy__' not in sys.builtin_module_names:
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -1766,14 +1766,14 @@
 
 def store(self, arr, i, offset, box):
 assert isinstance(box, interp_boxes.W_StringBox)
-# XXX simplify to range(box.dtype.get_size()) ?
 return self._store(arr.storage, i, offset, box)
 
 @jit.unroll_safe
 def _store(self, storage, i, offset, box):
 assert isinstance(box, interp_boxes.W_StringBox)
-for k in range(min(self.size, box.arr.size-offset)):
-storage[k + i] = box.arr.storage[k + offset]
+# XXX simplify to range(box.dtype.get_size()) ?
+for k in range(min(self.size, box.arr.size-box.ofs)):
+storage[k + offset + i] = box.arr.storage[k + box.ofs]
 
 def read(self, arr, i, offset, dtype=None):
 if dtype is None:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: np.unicode_ raises NotImplementedError

2013-08-30 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r66451:f8e77ae41719
Date: 2013-08-30 11:30 +0100
http://bitbucket.org/pypy/pypy/changeset/f8e77ae41719/

Log:np.unicode_ raises NotImplementedError

diff --git a/pypy/module/micronumpy/interp_boxes.py 
b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -396,6 +396,8 @@
 
 class W_UnicodeBox(W_CharacterBox):
 def descr__new__unicode_box(space, w_subtype, w_arg):
+raise OperationError(space.w_NotImplementedError, space.wrap(Unicode 
is not supported yet))
+
 from pypy.module.micronumpy.interp_dtype import new_unicode_dtype
 
 arg = space.unicode_w(unicode_from_object(space, w_arg))
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: (rguillebert, ronan, joanna) Progress on fancy indexing with booleans

2013-08-28 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r66377:9515e4524aaa
Date: 2013-08-27 17:56 +0100
http://bitbucket.org/pypy/pypy/changeset/9515e4524aaa/

Log:(rguillebert, ronan, joanna) Progress on fancy indexing with
booleans

diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -95,6 +95,12 @@
 if idx.get_size()  self.get_size():
 raise OperationError(space.w_ValueError,
  space.wrap(index out of range for array))
+idx_iter = idx.create_iter(self.get_shape())
+size = loop.count_all_true_iter(idx_iter, self.get_shape(), 
idx.get_dtype())
+if size != val.get_shape()[0]:
+raise OperationError(space.w_ValueError, space.wrap(NumPy boolean 
array indexing assignment 
+cannot assign 
%d input values to 
+the %d output 
values where the mask is true % (val.get_shape()[0],size)))
 loop.setitem_filter(self, idx, val)
 
 def _prepare_array_index(self, space, w_index):
diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -318,23 +318,27 @@
 lefti.next()
 return result
 
-count_all_true_driver = jit.JitDriver(name = 'numpy_count',
-  greens = ['shapelen', 'dtype'],
-  reds = 'auto')
 
 def count_all_true(arr):
-s = 0
 if arr.is_scalar():
 return arr.get_dtype().itemtype.bool(arr.get_scalar_value())
 iter = arr.create_iter()
-shapelen = len(arr.get_shape())
-dtype = arr.get_dtype()
+return count_all_true_iter(iter, arr.get_shape(), arr.get_dtype())
+
+count_all_true_iter_driver = jit.JitDriver(name = 'numpy_count',
+  greens = ['shapelen', 'dtype'],
+  reds = 'auto')
+def count_all_true_iter(iter, shape, dtype):
+s = 0
+shapelen = len(shape)
+dtype = dtype
 while not iter.done():
-count_all_true_driver.jit_merge_point(shapelen=shapelen, dtype=dtype)
+count_all_true_iter_driver.jit_merge_point(shapelen=shapelen, 
dtype=dtype)
 s += iter.getitem_bool()
 iter.next()
 return s
 
+
 getitem_filter_driver = jit.JitDriver(name = 'numpy_getitem_bool',
   greens = ['shapelen', 'arr_dtype',
 'index_dtype'],
diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -2354,6 +2354,12 @@
 def test_array_indexing_bool_specialcases(self):
 from numpypy import arange, array
 a = arange(6)
+try:
+a[a  3] = [1, 2]
+assert False, Should not work
+except ValueError:
+pass
+a = arange(6)
 a[a  3] = array([15])
 assert (a == [0, 1, 2, 3, 15, 15]).all()
 a = arange(6).reshape(3, 2)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix more of fancy indexing

2013-08-28 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r66378:dbb60d9a195a
Date: 2013-08-28 13:36 +0100
http://bitbucket.org/pypy/pypy/changeset/dbb60d9a195a/

Log:Fix more of fancy indexing

diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -88,7 +88,9 @@
 w_res = W_NDimArray.from_shape(space, res_shape, self.get_dtype(), 
w_instance=self)
 return loop.getitem_filter(w_res, self, arr)
 
-def setitem_filter(self, space, idx, val):
+def setitem_filter(self, space, idx, value):
+from pypy.module.micronumpy.interp_boxes import Box
+val = value
 if len(idx.get_shape())  1 and idx.get_shape() != self.get_shape():
 raise OperationError(space.w_ValueError,
  space.wrap(boolean index array should have 1 
dimension))
@@ -97,10 +99,16 @@
  space.wrap(index out of range for array))
 idx_iter = idx.create_iter(self.get_shape())
 size = loop.count_all_true_iter(idx_iter, self.get_shape(), 
idx.get_dtype())
-if size != val.get_shape()[0]:
+if len(val.get_shape())  0 and val.get_shape()[0]  1 and size  
val.get_shape()[0]:
 raise OperationError(space.w_ValueError, space.wrap(NumPy boolean 
array indexing assignment 
 cannot assign 
%d input values to 
 the %d output 
values where the mask is true % (val.get_shape()[0],size)))
+if val.get_shape() == [1]:
+box = val.descr_getitem(space, space.wrap(0))
+assert isinstance(box, Box)
+val = W_NDimArray(scalar.Scalar(val.get_dtype(), box))
+elif val.get_shape() == [0]:
+val.implementation.dtype = self.implementation.dtype
 loop.setitem_filter(self, idx, val)
 
 def _prepare_array_index(self, space, w_index):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Merge heads

2013-08-28 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r66379:c240d50f3830
Date: 2013-08-28 13:37 +0100
http://bitbucket.org/pypy/pypy/changeset/c240d50f3830/

Log:Merge heads

diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -5,7 +5,7 @@
 from rpython.tool.ansi_print import ansi_log
 from rpython.tool.pairtype import pair
 from rpython.tool.error import (format_blocked_annotation_error,
- AnnotatorError, gather_error, ErrorWrapper)
+ AnnotatorError, gather_error, ErrorWrapper, 
source_lines)
 from rpython.flowspace.model import (Variable, Constant, FunctionGraph,
   c_last_exception, checkgraph)
 from rpython.translator import simplify, transform
@@ -383,8 +383,8 @@
 try:
 unions = [annmodel.unionof(c1,c2) for c1, c2 in 
zip(oldcells,inputcells)]
 except annmodel.UnionError, e:
-e.args = e.args + (
-ErrorWrapper(gather_error(self, graph, block, None)),)
+# Add source code to the UnionError
+e.source = '\n'.join(source_lines(graph, block, None, long=True))
 raise
 # if the merged cells changed, we must redo the analysis
 if unions != oldcells:
diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -243,14 +243,16 @@
 
 if t2 is int:
 if int2.nonneg == False:
-raise UnionError, Merging %s and a possibly negative int 
is not allowed % t1
+raise UnionError(int1, int2, RPython cannot prove that 
these  + \
+integers are of the same signedness)
 knowntype = t1
 elif t1 is int:
 if int1.nonneg == False:
-raise UnionError, Merging %s and a possibly negative int 
is not allowed % t2
+raise UnionError(int1, int2, RPython cannot prove that 
these  + \
+integers are of the same signedness)
 knowntype = t2
 else:
-raise UnionError, Merging these types (%s, %s) is not 
supported % (t1, t2)
+raise UnionError(int1, int2)
 return SomeInteger(nonneg=int1.nonneg and int2.nonneg,
knowntype=knowntype)
 
@@ -551,9 +553,9 @@
 
 def union((tup1, tup2)):
 if len(tup1.items) != len(tup2.items):
-raise UnionError(cannot take the union of a tuple of length %d 
- and a tuple of length %d % (len(tup1.items),
-   len(tup2.items)))
+raise UnionError(tup1, tup2, RPython cannot unify tuples of 
+different length: %d versus %d % \
+(len(tup1.items), len(tup2.items)))
 else:
 unions = [unionof(x,y) for x,y in zip(tup1.items, tup2.items)]
 return SomeTuple(items = unions)
@@ -726,7 +728,8 @@
 else:
 basedef = ins1.classdef.commonbase(ins2.classdef)
 if basedef is None:
-raise UnionError(ins1, ins2)
+raise UnionError(ins1, ins2, RPython cannot unify instances 
+with no common base class)
 flags = ins1.flags
 if flags:
 flags = flags.copy()
@@ -768,7 +771,8 @@
 def union((iter1, iter2)):
 s_cont = unionof(iter1.s_container, iter2.s_container)
 if iter1.variant != iter2.variant:
-raise UnionError(merging incompatible iterators variants)
+raise UnionError(iter1, iter2,
+RPython cannot unify incompatible iterator variants)
 return SomeIterator(s_cont, *iter1.variant)
 
 
@@ -778,8 +782,7 @@
 if (bltn1.analyser != bltn2.analyser or
 bltn1.methodname != bltn2.methodname or
 bltn1.s_self is None or bltn2.s_self is None):
-raise UnionError(cannot merge two different builtin functions 
- or methods:\n  %r\n  %r % (bltn1, bltn2))
+raise UnionError(bltn1, bltn2)
 s_self = unionof(bltn1.s_self, bltn2.s_self)
 return SomeBuiltin(bltn1.analyser, s_self, methodname=bltn1.methodname)
 
@@ -976,8 +979,8 @@
 
 class __extend__(pairtype(SomeAddress, SomeObject)):
 def union((s_addr, s_obj)):
-raise UnionError, union of address and anything else makes no sense
+raise UnionError(s_addr, s_obj)
 
 class __extend__(pairtype(SomeObject, SomeAddress)):
 def union((s_obj, s_addr)):
-raise UnionError, union of address and anything else makes no sense
+raise UnionError(s_obj, s_addr)
diff --git a/rpython/annotator/listdef.py 

[pypy-commit] pypy default: Add two failing tests

2013-08-27 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r66360:53b319fef3b0
Date: 2013-08-27 15:38 +0100
http://bitbucket.org/pypy/pypy/changeset/53b319fef3b0/

Log:Add two failing tests

diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -1928,6 +1928,22 @@
 a.fill(12)
 assert (a == '1').all()
 
+def test_boolean_indexing(self):
+import numpypy as np
+a = np.zeros((1, 3))
+b = np.array([True])
+
+assert (a[b] == a).all()
+
+a[b] = 1.
+
+assert (a == [[1., 1., 1.]]).all()
+
+def test_boolean_array(self):
+import numpypy as np
+a = np.ndarray([1], dtype=bool)
+assert a[0] == True
+
 class AppTestMultiDim(BaseNumpyAppTest):
 def test_init(self):
 import numpypy
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix boolean indexing

2013-08-27 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r66361:c28b4d66af84
Date: 2013-08-27 15:41 +0100
http://bitbucket.org/pypy/pypy/changeset/c28b4d66af84/

Log:Fix boolean indexing

diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -370,7 +370,7 @@
 
 def setitem_filter(arr, index, value):
 arr_iter = arr.create_iter()
-index_iter = index.create_iter()
+index_iter = index.create_iter(arr.get_shape())
 value_iter = value.create_iter()
 shapelen = len(arr.get_shape())
 index_dtype = index.get_dtype()
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix ndarray(dtype=str).fill()

2013-08-26 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r66317:a4a455634894
Date: 2013-08-26 15:00 +0100
http://bitbucket.org/pypy/pypy/changeset/a4a455634894/

Log:Fix ndarray(dtype=str).fill()

diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -1922,6 +1922,12 @@
 a = numpy.arange(10.).reshape((5, 2))[::2]
 assert (loads(dumps(a)) == a).all()
 
+def test_string_filling(self):
+import numpypy as numpy
+a = numpy.empty((10,10), dtype='c1')
+a.fill(12)
+assert (a == '1').all()
+
 class AppTestMultiDim(BaseNumpyAppTest):
 def test_init(self):
 import numpypy
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -1764,12 +1764,16 @@
 arr.storage[i] = arg[i]
 return interp_boxes.W_StringBox(arr,  0, arr.dtype)
 
-@jit.unroll_safe
 def store(self, arr, i, offset, box):
 assert isinstance(box, interp_boxes.W_StringBox)
 # XXX simplify to range(box.dtype.get_size()) ?
+return self._store(arr.storage, i, offset, box)
+
+@jit.unroll_safe
+def _store(self, storage, i, offset, box):
+assert isinstance(box, interp_boxes.W_StringBox)
 for k in range(min(self.size, box.arr.size-offset)):
-arr.storage[k + i] = box.arr.storage[k + offset]
+storage[k + i] = box.arr.storage[k + offset]
 
 def read(self, arr, i, offset, dtype=None):
 if dtype is None:
@@ -1859,6 +1863,11 @@
 arr.storage[j] = '\x00'
 return interp_boxes.W_StringBox(arr,  0, arr.dtype)
 
+def fill(self, storage, width, box, start, stop, offset):
+from pypy.module.micronumpy.arrayimpl.concrete import 
ConcreteArrayNotOwning
+for i in xrange(start, stop, width):
+self._store(storage, i, offset, box)
+
 NonNativeStringType = StringType
 
 class UnicodeType(BaseType, BaseStringType):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Make numpy.character usable as a dtype (it's an alias for str)

2013-08-22 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r66290:36f863c1be94
Date: 2013-08-22 17:03 +0200
http://bitbucket.org/pypy/pypy/changeset/36f863c1be94/

Log:Make numpy.character usable as a dtype (it's an alias for str)

diff --git a/pypy/module/micronumpy/interp_dtype.py 
b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -685,7 +685,7 @@
 name='string',
 char='S',
 w_box_type = space.gettypefor(interp_boxes.W_StringBox),
-alternate_constructors=[space.w_str],
+alternate_constructors=[space.w_str, 
space.gettypefor(interp_boxes.W_CharacterBox)],
 aliases=[str],
 )
 self.w_unicodedtype = W_Dtype(
diff --git a/pypy/module/micronumpy/test/test_dtypes.py 
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -781,7 +781,7 @@
 def test_character_dtype(self):
 from numpypy import array, character
 x = array([[A, B], [C, D]], character)
-assert x == [[A, B], [C, D]]
+assert (x == [[A, B], [C, D]]).all()
 
 class AppTestRecordDtypes(BaseNumpyAppTest):
 spaceconfig = dict(usemodules=[micronumpy, struct, binascii])
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: numpy.rint(int) should return a float

2013-08-22 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r66300:8b0616ce3b90
Date: 2013-08-22 22:42 +0200
http://bitbucket.org/pypy/pypy/changeset/8b0616ce3b90/

Log:numpy.rint(int) should return a float

diff --git a/pypy/module/micronumpy/test/test_ufuncs.py 
b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -272,7 +272,7 @@
 assert rint(complex(inf, 1.5)) == complex(inf, 2.)
 assert rint(complex(0.5, inf)) == complex(0., inf)
 
-assert rint(sys.maxint) == sys.maxint
+assert rint(sys.maxint)  0.0
 
 def test_sign(self):
 from numpypy import array, sign, dtype
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -308,13 +308,6 @@
 return min(v1, v2)
 
 @simple_unary_op
-def rint(self, v):
-if isfinite(float(v)):
-return rfloat.round_double(float(v), 0, half_even=True)
-else:
-return v
-
-@simple_unary_op
 def ones_like(self, v):
 return 1
 
@@ -322,6 +315,10 @@
 def zeros_like(self, v):
 return 0
 
+@raw_unary_op
+def rint(self, v):
+float64 = Float64()
+return float64.rint(float64.box(v))
 
 class NonNativePrimitive(Primitive):
 _mixin_ = True
@@ -1036,6 +1033,25 @@
 else:
 return v1 + v2
 
+@simple_unary_op
+def rint(self, v):
+x = float(v)
+if isfinite(x):
+import math
+y = math.floor(x)
+r = x - y
+
+if r  0.5:
+y += 1.0
+
+if r == 0.5:
+r = y - 2.0 * math.floor(0.5 * y)
+if r == 1.0:
+y += 1.0
+return y
+else:
+return x
+
 class NonNativeFloat(NonNativePrimitive, Float):
 _mixin_ = True
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix a bug that makes translation fails sometimes

2013-08-20 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r66267:0ce8426280c8
Date: 2013-08-20 17:07 +0200
http://bitbucket.org/pypy/pypy/changeset/0ce8426280c8/

Log:Fix a bug that makes translation fails sometimes

diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -309,8 +309,8 @@
 
 @simple_unary_op
 def rint(self, v):
-if isfinite(v):
-return rfloat.round_double(v, 0, half_even=True)
+if isfinite(float(v)):
+return rfloat.round_double(float(v), 0, half_even=True)
 else:
 return v
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Add a failing test for the rint ufunc

2013-08-20 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r66271:a643b3face13
Date: 2013-08-21 03:03 +0200
http://bitbucket.org/pypy/pypy/changeset/a643b3face13/

Log:Add a failing test for the rint ufunc

diff --git a/pypy/module/micronumpy/test/test_ufuncs.py 
b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -257,6 +257,7 @@
 
 def test_rint(self):
 from numpypy import array, complex, rint, isnan
+import sys
 
 nnan, nan, inf, ninf = float('-nan'), float('nan'), float('inf'), 
float('-inf')
 
@@ -271,6 +272,8 @@
 assert rint(complex(inf, 1.5)) == complex(inf, 2.)
 assert rint(complex(0.5, inf)) == complex(0., inf)
 
+assert rint(sys.maxint) == sys.maxint
+
 def test_sign(self):
 from numpypy import array, sign, dtype
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Add a test for the character dtype (PyPy issue 1546)

2013-08-19 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r66247:9a5d859c4562
Date: 2013-08-20 01:16 +0200
http://bitbucket.org/pypy/pypy/changeset/9a5d859c4562/

Log:Add a test for the character dtype (PyPy issue 1546)

diff --git a/pypy/module/micronumpy/test/test_dtypes.py 
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -778,6 +778,11 @@
 from numpypy import unicode_
 assert isinstance(unicode_(3), unicode)
 
+def test_character_dtype(self):
+from numpypy import array, character
+x = array([[A, B], [C, D]], character)
+assert x == [[A, B], [C, D]]
+
 class AppTestRecordDtypes(BaseNumpyAppTest):
 spaceconfig = dict(usemodules=[micronumpy, struct, binascii])
 def test_create(self):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix PyPy issue 1544

2013-08-15 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r66164:ce1c1b2ad027
Date: 2013-08-15 19:07 +0200
http://bitbucket.org/pypy/pypy/changeset/ce1c1b2ad027/

Log:Fix PyPy issue 1544

diff --git a/pypy/objspace/std/complextype.py b/pypy/objspace/std/complextype.py
--- a/pypy/objspace/std/complextype.py
+++ b/pypy/objspace/std/complextype.py
@@ -201,7 +201,7 @@
 if w_z is not None:
 # __complex__() must return a complex or (float,int,long) object
 # (XXX should not use isinstance here)
-if not strict_typing and (space.isinstance_w(w_z, space.w_int) or 
+if not strict_typing and (space.isinstance_w(w_z, space.w_int) or
   space.isinstance_w(w_z, space.w_long) or
   space.isinstance_w(w_z, space.w_float)):
 return (space.float_w(w_z), 0.0)
@@ -214,8 +214,10 @@
 #
 # no '__complex__' method, so we assume it is a float,
 # unless it is an instance of some subclass of complex.
-if isinstance(w_complex, W_ComplexObject):
-return (w_complex.realval, w_complex.imagval)
+if space.is_true(space.isinstance(w_complex, 
space.gettypefor(W_ComplexObject))):
+real = space.float(space.getattr(w_complex, space.wrap(real)))
+imag = space.float(space.getattr(w_complex, space.wrap(imag)))
+return (space.float_w(real), space.float_w(imag))
 #
 # Check that it is not a string (on which space.float() would succeed).
 if (space.isinstance_w(w_complex, space.w_str) or
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Add myself

2013-07-19 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: extradoc
Changeset: r4999:08c9b80420a4
Date: 2013-07-19 16:05 +0200
http://bitbucket.org/pypy/extradoc/changeset/08c9b80420a4/

Log:Add myself

diff --git a/sprintinfo/london-2013/people.txt 
b/sprintinfo/london-2013/people.txt
--- a/sprintinfo/london-2013/people.txt
+++ b/sprintinfo/london-2013/people.txt
@@ -11,6 +11,7 @@
 Name  Arrive/Depart Accomodation 
  == ===
 Carl Friedrich Bolz  ?  ?
+Romain Guillebert?  ?
  == ===
 
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Merged in andrewsmedina/numpypy/ndarray-ptp (pull request #157)

2013-07-01 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: 
Changeset: r65140:1968b8b5d429
Date: 2013-07-01 15:39 +0200
http://bitbucket.org/pypy/pypy/changeset/1968b8b5d429/

Log:Merged in andrewsmedina/numpypy/ndarray-ptp (pull request #157)

implemented ndarray put

diff --git a/pypy/module/micronumpy/__init__.py 
b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -184,6 +184,7 @@
 appleveldefs = {}
 interpleveldefs = {
 'choose': 'interp_arrayops.choose',
+'put': 'interp_arrayops.put',
 'repeat': 'interp_arrayops.repeat',
 }
 submodules = {
diff --git a/pypy/module/micronumpy/interp_arrayops.py 
b/pypy/module/micronumpy/interp_arrayops.py
--- a/pypy/module/micronumpy/interp_arrayops.py
+++ b/pypy/module/micronumpy/interp_arrayops.py
@@ -192,6 +192,61 @@
 loop.choose(space, arr, choices, shape, dtype, out, MODES[mode])
 return out
 
+
+@unwrap_spec(mode=str)
+def put(space, w_arr, w_indices, w_values, mode='raise'):
+from pypy.module.micronumpy import constants
+from pypy.module.micronumpy.support import int_w
+
+arr = convert_to_array(space, w_arr)
+
+if mode not in constants.MODES:
+raise OperationError(space.w_ValueError,
+ space.wrap(mode %s not known % (mode,)))
+if not w_indices:
+raise OperationError(space.w_ValueError,
+ space.wrap(indice list cannot be empty))
+if not w_values:
+raise OperationError(space.w_ValueError,
+ space.wrap(value list cannot be empty))
+
+dtype = arr.get_dtype()
+
+if space.isinstance_w(w_indices, space.w_list):
+indices = space.listview(w_indices)
+else:
+indices = [w_indices]
+
+if space.isinstance_w(w_values, space.w_list):
+values = space.listview(w_values)
+else:
+values = [w_values]
+
+v_idx = 0
+for idx in indices:
+index = int_w(space, idx)
+
+if index  0 or index = arr.get_size():
+if constants.MODES[mode] == constants.MODE_RAISE:
+raise OperationError(space.w_ValueError, space.wrap(
+invalid entry in choice array))
+elif constants.MODES[mode] == constants.MODE_WRAP:
+index = index % arr.get_size()
+else:
+assert constants.MODES[mode] == constants.MODE_CLIP
+if index  0:
+index = 0
+else:
+index = arr.get_size() - 1
+
+value = values[v_idx]
+
+if v_idx + 1  len(values):
+v_idx += 1
+
+arr.setitem(space, [index], dtype.coerce(space, value))
+
+
 def diagonal(space, arr, offset, axis1, axis2):
 shape = arr.get_shape()
 shapelen = len(shape)
diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -550,9 +550,10 @@
 raise OperationError(space.w_NotImplementedError, space.wrap(
 ptp (peak to peak) not implemented yet))
 
-def descr_put(self, space, w_indices, w_values, w_mode='raise'):
-raise OperationError(space.w_NotImplementedError, space.wrap(
-put not implemented yet))
+@unwrap_spec(mode=str)
+def descr_put(self, space, w_indices, w_values, mode='raise'):
+from pypy.module.micronumpy.interp_arrayops import put
+put(space, self, w_indices, w_values, mode)
 
 def descr_resize(self, space, w_new_shape, w_refcheck=True):
 raise OperationError(space.w_NotImplementedError, space.wrap(
@@ -989,6 +990,7 @@
 prod = interp2app(W_NDimArray.descr_prod),
 max = interp2app(W_NDimArray.descr_max),
 min = interp2app(W_NDimArray.descr_min),
+put = interp2app(W_NDimArray.descr_put),
 argmax = interp2app(W_NDimArray.descr_argmax),
 argmin = interp2app(W_NDimArray.descr_argmin),
 all = interp2app(W_NDimArray.descr_all),
diff --git a/pypy/module/micronumpy/test/test_arrayops.py 
b/pypy/module/micronumpy/test/test_arrayops.py
--- a/pypy/module/micronumpy/test/test_arrayops.py
+++ b/pypy/module/micronumpy/test/test_arrayops.py
@@ -132,3 +132,26 @@
 x = array([0, 0, 0], dtype='i2')
 r = array([2, 1, 0]).choose([a, b, c], out=x)
 assert r.dtype == 'i2'
+
+def test_put_basic(self):
+from numpypy import arange, array
+a = arange(5)
+a.put([0, 2], [-44, -55])
+assert (a == array([-44, 1, -55, 3, 4])).all()
+a = arange(5)
+a.put([3, 4], 9)
+assert (a == array([0, 1, 2, 9, 9])).all()
+a = arange(5)
+a.put(1, [7, 8])
+assert (a == array([0, 7, 2, 3, 4])).all()
+
+def test_put_modes(self):
+from numpypy import array, arange
+a = arange(5)
+a.put(22, -5, mode='clip')
+  

[pypy-commit] pypy numpypy-nditer: Some progress on op_axes

2013-06-25 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-nditer
Changeset: r64977:ea9a8efd21c6
Date: 2013-06-25 17:35 +0200
http://bitbucket.org/pypy/pypy/changeset/ea9a8efd21c6/

Log:Some progress on op_axes

diff --git a/pypy/module/micronumpy/interp_nditer.py 
b/pypy/module/micronumpy/interp_nditer.py
--- a/pypy/module/micronumpy/interp_nditer.py
+++ b/pypy/module/micronumpy/interp_nditer.py
@@ -269,6 +269,7 @@
 parse_func_flags(space, self, w_flags)
 self.op_flags = parse_op_arg(space, 'op_flags', w_op_flags,
  len(self.seq), parse_op_flag)
+self.set_op_axes(space, w_op_axes)
 self.iters=[]
 self.shape = iter_shape = shape_agreement_multiple(space, self.seq)
 if self.tracked_index != :
@@ -288,6 +289,22 @@
 self.iters.append(BoxIterator(get_iter(space, self.order,
 self.seq[i], iter_shape), self.op_flags[i]))
 
+def set_op_axes(self, space, w_op_axes):
+if space.len_w(w_op_axes) != len(self.seq):
+raise OperationError(space.w_ValueError, space.wrap(op_axes must 
be a tuple/list matching the number of ops))
+op_axes = space.listview(w_op_axes)
+l = -1
+for w_axis in op_axes:
+if not space.is_(w_axis, space.w_None):
+axis_len = space.len_w(w_axis)
+if l == -1:
+l = axis_len
+elif axis_len != l:
+raise OperationError(space.w_ValueError, space.wrap(Each 
entry of op_axes must have the same size))
+self.op_axes.append([space.int_w(x) if not space.is_(x, 
space.w_None) else space.w_None for x in space.listview(w_axis)])
+if l == -1:
+raise OperationError(space.w_ValueError, space.wrap(If op_axes is 
provided, at least one list of axes must be contained within it))
+
 def descr_iter(self, space):
 return space.wrap(self)
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-nditer: Add a test for the multi_index flag

2013-06-18 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-nditer
Changeset: r64932:7245e102beb5
Date: 2013-06-19 02:08 +0200
http://bitbucket.org/pypy/pypy/changeset/7245e102beb5/

Log:Add a test for the multi_index flag

diff --git a/pypy/module/micronumpy/test/test_nditer.py 
b/pypy/module/micronumpy/test/test_nditer.py
--- a/pypy/module/micronumpy/test/test_nditer.py
+++ b/pypy/module/micronumpy/test/test_nditer.py
@@ -248,4 +248,22 @@
 assert (it.operands[1] == [[6, 22, 38], [54, 70, 86]]).all()
 assert (it.operands[1] == a.sum(axis=2)).all()
 
+def test_get_dtypes(self):
+from numpypy import array, dtype, nditer
+x = array([1, 2])
+y = array([1.0, 2.0])
+assert nditer([x, y]).dtypes == (dtype(int64), dtype(float64))
 
+def test_multi_index(self):
+import numpypy as np
+
+a = np.arange(6).reshape(2, 3)
+
+it = np.nditer(a, flags=['multi_index'])
+
+res = []
+while not it.finished:
+res.append((it[0], it.multi_index))
+it.iternext()
+
+assert res == [(0, (0, 0)), (1, (0, 1)), (2, (0, 2)), (3, (1, 0)), (4, 
(1, 1)), (5, (1, 2))]
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-nditer: Implement the multi_index flag

2013-06-18 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-nditer
Changeset: r64933:00c6b14ae653
Date: 2013-06-19 02:09 +0200
http://bitbucket.org/pypy/pypy/changeset/00c6b14ae653/

Log:Implement the multi_index flag

diff --git a/pypy/module/micronumpy/interp_nditer.py 
b/pypy/module/micronumpy/interp_nditer.py
--- a/pypy/module/micronumpy/interp_nditer.py
+++ b/pypy/module/micronumpy/interp_nditer.py
@@ -274,7 +274,11 @@
 if self.tracked_index != :
 if self.order == K:
 self.order = self.seq[0].implementation.order
-self.index_iter = IndexIterator(iter_shape, backward=self.order != 
self.tracked_index)
+if self.tracked_index == multi:
+backward = False
+else:
+backward = self.order != self.tracked_index
+self.index_iter = IndexIterator(iter_shape, backward=backward)
 if self.external_loop:
 for i in range(len(self.seq)):
 
self.iters.append(ExternalLoopIterator(get_external_loop_iter(space, self.order,
@@ -300,8 +304,7 @@
 'not implemented yet'))
 
 def descr_len(self, space):
-raise OperationError(space.w_NotImplementedError, space.wrap(
-'not implemented yet'))
+space.wrap(len(self.iters))
 
 def descr_next(self, space):
 for it in self.iters:
@@ -369,8 +372,10 @@
 'not implemented yet'))
 
 def descr_get_dtypes(self, space):
-raise OperationError(space.w_NotImplementedError, space.wrap(
-'not implemented yet'))
+res = [None] * len(self.seq)
+for i in range(len(self.seq)):
+res[i] = self.seq[i].descr_get_dtype(space)
+return space.newtuple(res)
 
 def descr_get_finished(self, space):
 return space.wrap(self.done)
@@ -380,22 +385,24 @@
 'not implemented yet'))
 
 def descr_get_has_index(self, space):
-return space.wrap(not self.tracked_index == )
+return space.wrap(self.tracked_index in [C, F])
 
 def descr_get_index(self, space):
-if self.tracked_index == :
+if not self.tracked_index in [C, F]:
 raise OperationError(space.w_ValueError, space.wrap(Iterator does 
not have an index))
 if self.done:
 raise OperationError(space.w_ValueError, space.wrap(Iterator is 
past the end))
 return space.wrap(self.index_iter.getvalue())
 
 def descr_get_has_multi_index(self, space):
-raise OperationError(space.w_NotImplementedError, space.wrap(
-'not implemented yet'))
+return space.wrap(self.tracked_index == multi)
 
 def descr_get_multi_index(self, space):
-raise OperationError(space.w_NotImplementedError, space.wrap(
-'not implemented yet'))
+if not self.tracked_index == multi:
+raise OperationError(space.w_ValueError, space.wrap(Iterator is 
not tracking a multi-index))
+if self.done:
+raise OperationError(space.w_ValueError, space.wrap(Iterator is 
past the end))
+return space.newtuple([space.wrap(x) for x in self.index_iter.index])
 
 def descr_get_iterationneedsapi(self, space):
 raise OperationError(space.w_NotImplementedError, space.wrap(
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-nditer: Make sure nditer.index does not give an index when the iterator is consumed

2013-06-17 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-nditer
Changeset: r64918:97a5ef769a6c
Date: 2013-06-17 15:43 +0200
http://bitbucket.org/pypy/pypy/changeset/97a5ef769a6c/

Log:Make sure nditer.index does not give an index when the iterator is
consumed

diff --git a/pypy/module/micronumpy/interp_nditer.py 
b/pypy/module/micronumpy/interp_nditer.py
--- a/pypy/module/micronumpy/interp_nditer.py
+++ b/pypy/module/micronumpy/interp_nditer.py
@@ -264,6 +264,7 @@
 self.reduce_ok = False
 self.zerosize_ok = False
 self.index_iter = None
+self.done = False
 if space.isinstance_w(w_seq, space.w_tuple) or \
space.isinstance_w(w_seq, space.w_list):
 w_seq_as_list = space.listview(w_seq)
@@ -308,6 +309,7 @@
 if not it.done():
 break
 else:
+self.done = True
 raise OperationError(space.w_StopIteration, space.w_None)
 res = []
 if self.index_iter:
@@ -370,6 +372,8 @@
 def descr_get_index(self, space):
 if self.tracked_index == :
 raise OperationError(space.w_ValueError, space.wrap(Iterator does 
not have an index))
+if self.done:
+raise OperationError(space.w_ValueError, space.wrap(Iterator is 
past the end))
 return space.wrap(self.index_iter.getvalue())
 
 def descr_get_has_multi_index(self, space):
diff --git a/pypy/module/micronumpy/test/test_nditer.py 
b/pypy/module/micronumpy/test/test_nditer.py
--- a/pypy/module/micronumpy/test/test_nditer.py
+++ b/pypy/module/micronumpy/test/test_nditer.py
@@ -76,6 +76,12 @@
 for value in it:
 r.append((value, it.index))
 assert r == [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]
+exc = None
+try:
+it.index
+except ValueError, e:
+exc = e
+assert exc
 
 r = []
 it = nditer(a, flags=['f_index'])
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


  1   2   >