[pypy-commit] cffi cffi-1.0: Add a test
Author: Armin Rigo Branch: cffi-1.0 Changeset: r2043:c8cd3c14b3e8 Date: 2015-05-18 12:42 +0200 http://bitbucket.org/cffi/cffi/changeset/c8cd3c14b3e8/ Log:Add a test diff --git a/testing/cffi1/test_re_python.py b/testing/cffi1/test_re_python.py --- a/testing/cffi1/test_re_python.py +++ b/testing/cffi1/test_re_python.py @@ -76,6 +76,9 @@ e = py.test.raises(ffi.error, ffi.dlclose, lib) assert str(e.value).startswith( "library '%s' is already closed" % (extmod,)) +e = py.test.raises(ffi.error, getattr, lib, 'add42') +assert str(e.value) == ( +"library '%s' has been closed" % (extmod,)) def test_constant_via_lib(): from re_python_pysrc import ffi ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cffi-1.0: Add a test and fix
Author: Armin Rigo Branch: cffi-1.0 Changeset: r77372:3bafa1b4e46a Date: 2015-05-18 12:42 +0200 http://bitbucket.org/pypy/pypy/changeset/3bafa1b4e46a/ Log:Add a test and fix diff --git a/pypy/module/_cffi_backend/cdlopen.py b/pypy/module/_cffi_backend/cdlopen.py --- a/pypy/module/_cffi_backend/cdlopen.py +++ b/pypy/module/_cffi_backend/cdlopen.py @@ -31,6 +31,9 @@ dlclose(self.libhandle) def cdlopen_fetch(self, name): +if not self.libhandle: +raise oefmt(self.ffi.w_FFIError, "library '%s' has been closed", +self.libname) try: cdata = dlsym(self.libhandle, name) except KeyError: diff --git a/pypy/module/_cffi_backend/test/test_re_python.py b/pypy/module/_cffi_backend/test/test_re_python.py --- a/pypy/module/_cffi_backend/test/test_re_python.py +++ b/pypy/module/_cffi_backend/test/test_re_python.py @@ -105,6 +105,9 @@ e = raises(ffi.error, ffi.dlclose, lib) assert str(e.value) == ( "library '%s' is already closed" % (self.extmod,)) +e = raises(ffi.error, getattr, lib, 'add42') +assert str(e.value) == ( +"library '%s' has been closed" % (self.extmod,)) def test_constant_via_lib(self): from re_python_pysrc import ffi ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] cffi cffi-1.0: One more pass through this doc
Author: Armin Rigo Branch: cffi-1.0 Changeset: r2045:84e1cd77b89c Date: 2015-05-18 13:39 +0200 http://bitbucket.org/cffi/cffi/changeset/84e1cd77b89c/ Log:One more pass through this doc diff --git a/doc/source/cdef.rst b/doc/source/cdef.rst --- a/doc/source/cdef.rst +++ b/doc/source/cdef.rst @@ -406,22 +406,32 @@ You can use one of the following functions to actually generate the .py or .c file prepared with ``ffi.set_source()`` and ``ffi.cdef()``. +Note that these function won't overwrite a .py/.c file with exactly +the same content, to preserve the mtime. In some cases where you need +the mtime to be updated anyway, delete the file before calling the +functions. + **ffi.compile(tmpdir='.'):** explicitly generate the .py or .c file, -and (in the second case) compile it. The output file is (or are) put -in the directory given by ``tmpdir``. +and (if .c) compile it. The output file is (or are) put in the +directory given by ``tmpdir``. In the examples given here, we use +``if __name__ == "__main__": ffi.compile()`` in the build scripts---if +they are directly executed, this makes them rebuild the .py/.c file in +the current directory. -**ffi.emit_python_code(filename):** same as ``ffi.compile()`` in ABI -mode (i.e. checks that ``ffi.compile()`` would have generated a Python -file). The file to write is explicitly named. +**ffi.emit_python_code(filename):** generate the given .py file (same +as ``ffi.compile()`` for ABI mode, with an explicitly-named file to +write). If you choose, you can include this .py file pre-packaged in +your own distributions: it is identical for any Python version (2 or +3). **ffi.emit_c_code(filename):** generate the given .c file (for API mode) without compiling it. Can be used if you have some other method to compile it, e.g. if you want to integrate with some larger build system that will compile this file for you. You can also distribute -the .c file: unless the build script you used depends on the OS, the -.c file itself is generic (it would be exactly the same if produced on -a different OS, with a different version of CPython, or with PyPy; it -is done with generating the appropriate ``#ifdef``). +the .c file: unless the build script you used depends on the OS or +platform, the .c file itself is generic (it would be exactly the same +if produced on a different OS, with a different version of CPython, or +with PyPy; it is done with generating the appropriate ``#ifdef``). **ffi.distutils_extension(tmpdir='build', verbose=True):** for distutils-based ``setup.py`` files. Calling this creates the .c file @@ -430,9 +440,12 @@ For Setuptools, you use instead the line ``cffi_modules=["path/to/foo_build.py:ffi"]`` in ``setup.py``. This -line will internally cause Setuptools to call -``cffi.setuptools_ext.cffi_modules()``, which writes the .c file and -attaches an ``Extension`` instance automatically. +line asks Setuptools to import and use a helper provided by CFFI, +which in turn executes the file ``path/to/foo_build.py`` (as with +``execfile()``) and looks up its global variable called ``ffi``. You +can also say ``cffi_modules=["path/to/foo_build.py:maker"]``, where +``maker`` names a global function; it is called with no argument and +is supposed to return a ``FFI`` object. ffi.include(): combining multiple CFFI interfaces @@ -548,7 +561,9 @@ deprecated. ``ffi.verify(c_header_source, tmpdir=.., ext_package=.., modulename=.., flags=.., **kwargs)`` makes and compiles a C file from the ``ffi.cdef()``, like ``ffi.set_source()`` in API mode, and then -immediately loads and returns the dynamic library object. +immediately loads and returns the dynamic library object. Some +non-trivial logic is used to decide if the dynamic library must be +recompiled or not; see below for ways to control it. The ``c_header_source`` and the extra keyword arguments have the same meaning as in ``ffi.set_source()``. @@ -591,10 +606,10 @@ check. Be sure to have other means of clearing the ``tmpdir`` whenever you change your sources. -* ``source_extension`` has the same meaning as in - ``ffi.set_source()``. +* ``source_extension`` has the same meaning as in ``ffi.set_source()``. -* The optional ``flags`` argument has been added, see ``man dlopen`` +* The optional ``flags`` argument has been added in version 0.9; + see ``man dlopen`` (ignored on Windows). It defaults to ``ffi.RTLD_NOW``. (With ``ffi.set_source()``, you would use ``sys.setdlopenflags()``.) @@ -621,8 +636,8 @@ strings. This creates more and more files in the ``__pycache__`` directory. It is recommended that you clean it up from time to time. A nice way to do that is to add, in your test suite, a call to -``cffi.verifier.cleanup_tmpdir()``. Alternatively, you can just -completely remove the ``__pycache__`` directory. +``cffi.verifier.cleanup_tmpdir()``. Alternatively, you can manually +remove the whole ``__pycache__`` directory. An alternative cache direc
[pypy-commit] cffi cffi-1.0: Initialize the __name__ and __file__ arguments when we're about to
Author: Armin Rigo Branch: cffi-1.0 Changeset: r2044:a96e6eedc5cd Date: 2015-05-18 13:39 +0200 http://bitbucket.org/cffi/cffi/changeset/a96e6eedc5cd/ Log:Initialize the __name__ and __file__ arguments when we're about to execfile() the build script diff --git a/cffi/setuptools_ext.py b/cffi/setuptools_ext.py --- a/cffi/setuptools_ext.py +++ b/cffi/setuptools_ext.py @@ -42,7 +42,7 @@ rewritten + ':' + ffi_var_name,) error("%r does not name an existing file%s" % (build_file_name, ext)) -mod_vars = {} +mod_vars = {'__name__': '__cffi__', '__file__': build_file_name} execfile(build_file_name, mod_vars) try: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] cffi cffi-1.0: rewrites
Author: Armin Rigo Branch: cffi-1.0 Changeset: r2046:7600c89e80a6 Date: 2015-05-18 13:43 +0200 http://bitbucket.org/cffi/cffi/changeset/7600c89e80a6/ Log:rewrites diff --git a/doc/source/cdef.rst b/doc/source/cdef.rst --- a/doc/source/cdef.rst +++ b/doc/source/cdef.rst @@ -722,11 +722,10 @@ import to "work" even if the ``_foo`` module was not generated.) Writing a ``setup.py`` script that works both with CFFI 0.9 and 1.0 -requires explicitly checking the version of CFFI that we are going to -download and install---which we can assume is the latest one unless -we're running on PyPy:: +requires explicitly checking the version of CFFI that we can have---it +is hard-coded as a built-in module in PyPy:: -if '_cffi_backend' in sys.builtin_module_names: # pypy +if '_cffi_backend' in sys.builtin_module_names: # PyPy import _cffi_backend requires_cffi = "cffi==" + _cffi_backend.__version__ else: @@ -736,7 +735,7 @@ ``setup()`` as needed, e.g.:: if requires_cffi.startswith("cffi==0."): -# backward compatibility: we require "cffi==0.*" +# backward compatibility: we have "cffi==0.*" from package.foo_build import ffi extra_args = dict( ext_modules=[ffi.verifier.get_extension()], @@ -744,6 +743,7 @@ ) else: extra_args = dict( +setup_requires=[requires_cffi], cffi_modules=['package/foo_build.py:ffi'], ) setup( ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vecopt: improved the scheduling (missed to emit pack/unpack ops), work in progress
Author: Richard Plangger Branch: vecopt Changeset: r77373:c0d72e0205ae Date: 2015-05-18 15:17 +0200 http://bitbucket.org/pypy/pypy/changeset/c0d72e0205ae/ Log:improved the scheduling (missed to emit pack/unpack ops), work in progress 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 @@ -2,6 +2,7 @@ It should not be imported by the module itself """ import re +import py from pypy.interpreter import special from pypy.interpreter.baseobjspace import InternalSpaceCache, W_Root, ObjSpace from pypy.interpreter.error import OperationError diff --git a/pypy/module/micronumpy/test/test_zjit.py b/pypy/module/micronumpy/test/test_zjit.py --- a/pypy/module/micronumpy/test/test_zjit.py +++ b/pypy/module/micronumpy/test/test_zjit.py @@ -170,16 +170,23 @@ return """ a = astype(|30|, int32) b = a + 1i -c = a + 2.0 x1 = b -> 7 x2 = b -> 8 -x3 = c -> 11 -x4 = c -> 12 -x1 + x2 + x3 + x4 +x1 + x2 """ +#return """ +#a = astype(|30|, int32) +#b = a + 1i +#c = a + 2.0 +#x1 = b -> 7 +#x2 = b -> 8 +#x3 = c -> 11 +#x4 = c -> 12 +#x1 + x2 + x3 + x4 +#""" def test_int32_add_const(self): result = self.run("int32_add_const") -assert int(result) == 7+1+8+1+11+2+12+2 +assert int(result) == 7+1+8+1 self.check_vectorized(1, 1) diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py --- a/rpython/jit/backend/x86/assembler.py +++ b/rpython/jit/backend/x86/assembler.py @@ -865,8 +865,14 @@ # def mov(self, from_loc, to_loc): -if (isinstance(from_loc, RegLoc) and from_loc.is_xmm) or (isinstance(to_loc, RegLoc) and to_loc.is_xmm): -self.mc.MOVSD(to_loc, from_loc) +from_xmm = isinstance(from_loc, RegLoc) and from_loc.is_xmm +to_xmm = isinstance(to_loc, RegLoc) and to_loc.is_xmm +if from_xmm or to_xmm: +if from_xmm and to_xmm: +# copy 128-bit from -> to +self.mc.MOVAPD(to_loc, from_loc) +else: +self.mc.MOVSD(to_loc, from_loc) else: assert to_loc is not ebp self.mc.MOV(to_loc, from_loc) @@ -2547,17 +2553,29 @@ srcloc, sizeloc, tosizeloc = arglocs size = sizeloc.value tosize = tosizeloc.value -if size == 8 and tosize == 4: +if size == 4 and tosize == 8: +scratch = X86_64_SCRATCH_REG.value +print resloc, "[0] <- int64(", srcloc, "[0])" +print resloc, "[1] <- int64(", srcloc, "[1])" +self.mc.PEXTRD_rxi(scratch, srcloc.value, 1) +self.mc.PINSRQ_xri(resloc.value, scratch, 1) +self.mc.PEXTRD_rxi(scratch, srcloc.value, 0) +self.mc.PINSRQ_xri(resloc.value, scratch, 0) +elif size == 8 and tosize == 4: # is there a better sequence to move them? -self.mc.MOVDQU(resloc, srcloc) -self.mc.PSRLDQ(srcloc, 8) -self.mc.PUNPCKLDQ(resloc, srcloc) +scratch = X86_64_SCRATCH_REG.value +print resloc, "[0] <- int32(", srcloc, "[0])" +print resloc, "[1] <- int32(", srcloc, "[1])" +self.mc.PEXTRQ_rxi(scratch, srcloc.value, 0) +self.mc.PINSRD_xri(resloc.value, scratch, 0) +self.mc.PEXTRQ_rxi(scratch, srcloc.value, 1) +self.mc.PINSRD_xri(resloc.value, scratch, 1) else: py.test.set_trace() raise NotImplementedError("sign ext missing") def genop_vec_float_expand(self, op, arglocs, resloc): -loc0, countloc = arglocs +loc0, sizeloc, countloc = arglocs count = countloc.value if count == 1: raise NotImplementedError("expand count 1") @@ -2620,31 +2638,32 @@ si = srcidx ri = residx k = count +print resultloc,"[", residx, "] <- ",sourceloc,"[",srcidx,"] count", count while k > 0: if size == 8: if resultloc.is_xmm: self.mc.PEXTRQ_rxi(X86_64_SCRATCH_REG.value, sourceloc.value, si) -self.mc.PINSRQ_xri(resloc.value, X86_64_SCRATCH_REG.value, ri) +self.mc.PINSRQ_xri(resultloc.value, X86_64_SCRATCH_REG.value, ri) else: -self.mc.PEXTRQ_rxi(resloc.value, sourceloc.value, si) +self.mc.PEXTRQ_rxi(resultloc.value, sourceloc.value, si) elif size == 4: if resultloc.is_xmm: self.mc.PEXTRD_rxi(X86_64_SCRATCH_REG.value, sourceloc.value, si) -self.mc.PINSRD_xri(resloc.value, X86_64_SCRATC
[pypy-commit] cffi cffi-1.0: Forgot about the version checking and specifying in the ABI-mode modules
Author: Armin Rigo Branch: cffi-1.0 Changeset: r2047:2d4469c2fec5 Date: 2015-05-18 17:25 +0200 http://bitbucket.org/cffi/cffi/changeset/2d4469c2fec5/ Log:Forgot about the version checking and specifying in the ABI-mode modules diff --git a/c/cdlopen.c b/c/cdlopen.c --- a/c/cdlopen.c +++ b/c/cdlopen.c @@ -139,7 +139,7 @@ static char *keywords[] = {"module_name", "_version", "_types", "_globals", "_struct_unions", "_enums", "_typenames", "_includes", NULL}; -char *ffiname = NULL, *types = NULL, *building = NULL; +char *ffiname = "?", *types = NULL, *building = NULL; Py_ssize_t version = -1; Py_ssize_t types_len = 0; PyObject *globals = NULL, *struct_unions = NULL, *enums = NULL; @@ -163,6 +163,15 @@ } ffi->ctx_is_nonempty = 1; +if (version == -1 && types_len == 0) +return 0; +if (version < CFFI_VERSION_MIN || version > CFFI_VERSION_MAX) { +PyErr_Format(PyExc_ImportError, + "cffi out-of-line Python module '%s' has unknown " + "version %p", ffiname, (void *)version); +return -1; +} + if (types_len > 0) { /* unpack a string of 4-byte entries into an array of _cffi_opcode_t */ _cffi_opcode_t *ntypes; diff --git a/c/cffi1_module.c b/c/cffi1_module.c --- a/c/cffi1_module.c +++ b/c/cffi1_module.c @@ -2,6 +2,9 @@ #include "parse_c_type.c" #include "realize_c_type.c" +#define CFFI_VERSION_MIN0x2601 +#define CFFI_VERSION_MAX0x26FF + typedef struct FFIObject_s FFIObject; typedef struct LibObject_s LibObject; @@ -136,9 +139,6 @@ #endif } -#define CFFI_VERSION_MIN0x2601 -#define CFFI_VERSION_MAX0x26FF - static PyObject *b_init_cffi_1_0_external_module(PyObject *self, PyObject *arg) { PyObject *m; diff --git a/cffi/recompiler.py b/cffi/recompiler.py --- a/cffi/recompiler.py +++ b/cffi/recompiler.py @@ -2,6 +2,8 @@ from . import ffiplatform, model from .cffi_opcode import * +VERSION = "0x2601" + try: int_type = (int, long) except NameError:# Python 3 @@ -375,7 +377,7 @@ prnt('PyMODINIT_FUNC') prnt('_cffi_pypyinit_%s(const void *p[])' % (base_module_name,)) prnt('{') -prnt('p[0] = (const void *)0x2601;') +prnt('p[0] = (const void *)%s;' % VERSION) prnt('p[1] = &_cffi_type_context;') prnt('}') # on Windows, distutils insists on putting init_cffi_xyz in @@ -393,15 +395,15 @@ prnt('PyMODINIT_FUNC') prnt('PyInit_%s(void)' % (base_module_name,)) prnt('{') -prnt(' return _cffi_init("%s", 0x2601, &_cffi_type_context);' % ( -self.module_name,)) +prnt(' return _cffi_init("%s", %s, &_cffi_type_context);' % ( +self.module_name, VERSION)) prnt('}') prnt('#else') prnt('PyMODINIT_FUNC') prnt('init%s(void)' % (base_module_name,)) prnt('{') -prnt(' _cffi_init("%s", 0x2601, &_cffi_type_context);' % ( -self.module_name,)) +prnt(' _cffi_init("%s", %s, &_cffi_type_context);' % ( +self.module_name, VERSION)) prnt('}') prnt('#endif') @@ -442,6 +444,7 @@ prnt('from %s import ffi as _ffi%d' % (included_module_name, i)) prnt() prnt("ffi = _cffi_backend.FFI('%s'," % (self.module_name,)) +prnt("_version = %s," % (VERSION,)) # # the '_types' keyword argument self.cffi_types = tuple(self.cffi_types)# don't change any more diff --git a/testing/cffi1/test_dlopen.py b/testing/cffi1/test_dlopen.py --- a/testing/cffi1/test_dlopen.py +++ b/testing/cffi1/test_dlopen.py @@ -13,6 +13,7 @@ import _cffi_backend ffi = _cffi_backend.FFI('test_simple', +_version = 0x2601, _types = b'\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x00\x0F', _globals = (b'\xFF\xFF\xFF\x1FBB',42,b'\x00\x00\x00\x23close',0,b'\x00\x00\x01\x21somevar',0), ) @@ -66,6 +67,7 @@ import _cffi_backend ffi = _cffi_backend.FFI('test_typename', +_version = 0x2601, _types = b'\x00\x00\x07\x01', _typenames = (b'\x00\x00\x00\x00foobar_t',), ) @@ -80,6 +82,7 @@ import _cffi_backend ffi = _cffi_backend.FFI('test_enum', +_version = 0x2601, _types = b'\x00\x00\x00\x0B', _globals = (b'\xFF\xFF\xFF\x0BAA',0,b'\xFF\xFF\xFF\x0BBB',1,b'\xFF\xFF\xFF\x0BCC',-42), _enums = (b'\x00\x00\x00\x00\x00\x00\x00\x15myenum_e\x00AA,BB,CC',), @@ -95,6 +98,7 @@ import _cffi_backend ffi = _cffi_backend.FFI('test_struct', +_version = 0x2601, _types = b'\x00\x00\x07\x01\x00\x00\x03\x01\x00\x00\x01\x07\x00\x00\x00\x09\x00\x00\x01\x09', _struct_unions = ((b'\x00\x00\x00\x03\x00\x00\x00\x10bar_s',),(b'\x00\x00\x00\x04\x00\x00\x00\x02foo_s',b'\x00\x00\x00\x11a',b'\x00\x00\x02\x11b')), ) @@ -110,6 +114,7 @@ import _cffi_backend ffi = _cffi_backend.FFI('test_includ
[pypy-commit] pypy cffi-1.0: Update to cffi/2d4469c2fec5
Author: Armin Rigo Branch: cffi-1.0 Changeset: r77374:fd3f5bfeb3b8 Date: 2015-05-18 17:43 +0200 http://bitbucket.org/pypy/pypy/changeset/fd3f5bfeb3b8/ Log:Update to cffi/2d4469c2fec5 diff --git a/pypy/module/_cffi_backend/cdlopen.py b/pypy/module/_cffi_backend/cdlopen.py --- a/pypy/module/_cffi_backend/cdlopen.py +++ b/pypy/module/_cffi_backend/cdlopen.py @@ -10,7 +10,7 @@ ENUM_S, TYPENAME_S, ll_set_cdl_realize_global_int) from pypy.module._cffi_backend.realize_c_type import getop from pypy.module._cffi_backend.lib_obj import W_LibObject -from pypy.module._cffi_backend import cffi_opcode +from pypy.module._cffi_backend import cffi_opcode, cffi1_module class W_DlOpenLibObject(W_LibObject): @@ -118,6 +118,13 @@ # otherwise ll2ctypes explodes. I don't want to know :-( rffi.cast(lltype.Signed, ffi.ctxobj) +if version == -1 and not types: +return +if not (cffi1_module.VERSION_MIN <= version <= cffi1_module.VERSION_MAX): +raise oefmt(space.w_ImportError, +"cffi out-of-line Python module '%s' has unknown version %s", +module_name, hex(version)) + if types: # unpack a string of 4-byte entries into an array of _cffi_opcode_t n = len(types) // 4 diff --git a/pypy/module/_cffi_backend/ffi_obj.py b/pypy/module/_cffi_backend/ffi_obj.py --- a/pypy/module/_cffi_backend/ffi_obj.py +++ b/pypy/module/_cffi_backend/ffi_obj.py @@ -155,8 +155,8 @@ m1, s12, m2, s23, m3, w_x) -@unwrap_spec(module_name="str_or_None", _version=int, _types="str_or_None") -def descr_init(self, module_name=None, _version=-1, _types=None, +@unwrap_spec(module_name=str, _version=int, _types=str) +def descr_init(self, module_name='?', _version=-1, _types='', w__globals=None, w__struct_unions=None, w__enums=None, w__typenames=None, w__includes=None): from pypy.module._cffi_backend import cdlopen diff --git a/pypy/module/_cffi_backend/test/test_re_python.py b/pypy/module/_cffi_backend/test/test_re_python.py --- a/pypy/module/_cffi_backend/test/test_re_python.py +++ b/pypy/module/_cffi_backend/test/test_re_python.py @@ -172,3 +172,10 @@ e = raises(ffi.error, getattr, lib, 'no_such_globalvar') assert str(e.value).startswith( "symbol 'no_such_globalvar' not found in library '") + +def test_check_version(self): +import _cffi_backend +e = raises(ImportError, _cffi_backend.FFI, +"foobar", _version=0x2594) +assert str(e.value).startswith( +"cffi out-of-line Python module 'foobar' has unknown version") ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cffi-1.0: Update the importing tool
Author: Armin Rigo Branch: cffi-1.0 Changeset: r77375:64114b649ca5 Date: 2015-05-18 18:12 +0200 http://bitbucket.org/pypy/pypy/changeset/64114b649ca5/ Log:Update the importing tool diff --git a/pypy/tool/import_cffi.py b/pypy/tool/import_cffi.py --- a/pypy/tool/import_cffi.py +++ b/pypy/tool/import_cffi.py @@ -18,16 +18,11 @@ pypydir = py.path.local(__file__).join('..', '..') cffi_dest = pypydir.join('..', 'lib_pypy', 'cffi') cffi_dest.ensure(dir=1) -cffi1_dest = pypydir.join('..', 'lib_pypy', '_cffi1') -cffi1_dest.ensure(dir=1) test_dest = pypydir.join('module', 'test_lib_pypy', 'cffi_tests') test_dest.ensure(dir=1) -for p in cffi_dir.join('cffi').visit(fil='*.py'): +for p in (list(cffi_dir.join('cffi').visit(fil='*.py')) + + list(cffi_dir.join('cffi').visit(fil='*.h'))): cffi_dest.join('..', p.relto(cffi_dir)).write(p.read()) -for p in cffi_dir.join('_cffi1').visit(fil='*.py'): -cffi1_dest.join('..', p.relto(cffi_dir)).write(p.read()) -for p in cffi_dir.join('_cffi1').visit(fil='*.h'): -cffi1_dest.join('..', p.relto(cffi_dir)).write(p.read()) for p in cffi_dir.join('testing').visit(fil='*.py'): path = test_dest.join(p.relto(cffi_dir.join('testing'))) path.join('..').ensure(dir=1) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cffi-1.0: Import cffi-1.0/2d4469c2fec5
Author: Armin Rigo Branch: cffi-1.0 Changeset: r77376:a9cf96f5ec51 Date: 2015-05-18 18:12 +0200 http://bitbucket.org/pypy/pypy/changeset/a9cf96f5ec51/ Log:Import cffi-1.0/2d4469c2fec5 diff too long, truncating to 2000 out of 21936 lines diff --git a/lib_pypy/_cffi1/__init__.py b/lib_pypy/_cffi1/__init__.py deleted file mode 100644 --- a/lib_pypy/_cffi1/__init__.py +++ /dev/null @@ -1,1 +0,0 @@ -from .recompiler import make_c_source, recompile diff --git a/lib_pypy/_cffi1/_cffi_include.h b/lib_pypy/_cffi1/_cffi_include.h deleted file mode 100644 --- a/lib_pypy/_cffi1/_cffi_include.h +++ /dev/null @@ -1,217 +0,0 @@ -#include -#include -#include "parse_c_type.h" - -/* this block of #ifs should be kept exactly identical between - c/_cffi_backend.c, cffi/vengine_cpy.py, cffi/vengine_gen.py */ -#if defined(_MSC_VER) -# include/* for alloca() */ -# if _MSC_VER < 1600 /* MSVC < 2010 */ - typedef __int8 int8_t; - typedef __int16 int16_t; - typedef __int32 int32_t; - typedef __int64 int64_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; - typedef unsigned __int64 uint64_t; - typedef __int8 int_least8_t; - typedef __int16 int_least16_t; - typedef __int32 int_least32_t; - typedef __int64 int_least64_t; - typedef unsigned __int8 uint_least8_t; - typedef unsigned __int16 uint_least16_t; - typedef unsigned __int32 uint_least32_t; - typedef unsigned __int64 uint_least64_t; - typedef __int8 int_fast8_t; - typedef __int16 int_fast16_t; - typedef __int32 int_fast32_t; - typedef __int64 int_fast64_t; - typedef unsigned __int8 uint_fast8_t; - typedef unsigned __int16 uint_fast16_t; - typedef unsigned __int32 uint_fast32_t; - typedef unsigned __int64 uint_fast64_t; - typedef __int64 intmax_t; - typedef unsigned __int64 uintmax_t; -# else -# include -# endif -# if _MSC_VER < 1800 /* MSVC < 2013 */ - typedef unsigned char _Bool; -# endif -#else -# include -# if (defined (__SVR4) && defined (__sun)) || defined(_AIX) -# include -# endif -#endif - - -/** CPython-specific section **/ -#ifndef PYPY_VERSION - - -#if PY_MAJOR_VERSION < 3 -# undef PyCapsule_CheckExact -# undef PyCapsule_GetPointer -# define PyCapsule_CheckExact(capsule) (PyCObject_Check(capsule)) -# define PyCapsule_GetPointer(capsule, name) \ -(PyCObject_AsVoidPtr(capsule)) -#endif - -#if PY_MAJOR_VERSION >= 3 -# define PyInt_FromLong PyLong_FromLong -#endif - -#define _cffi_from_c_double PyFloat_FromDouble -#define _cffi_from_c_float PyFloat_FromDouble -#define _cffi_from_c_long PyInt_FromLong -#define _cffi_from_c_ulong PyLong_FromUnsignedLong -#define _cffi_from_c_longlong PyLong_FromLongLong -#define _cffi_from_c_ulonglong PyLong_FromUnsignedLongLong - -#define _cffi_to_c_double PyFloat_AsDouble -#define _cffi_to_c_float PyFloat_AsDouble - -#define _cffi_from_c_int(x, type)\ -(((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)\ - : (type)_cffi_to_c_i8(o)) : \ - sizeof(type) == 2 ? (((type)-1) > 0 ? (type)_cffi_to_c_u16(o) \ - : (type)_cffi_to_c_i16(o)) :\ - sizeof(type) == 4 ? (((type)-1) > 0 ? (type)_cffi_to_c_u32(o) \ - : (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), (type)0)) - -#define _cffi_to_c_i8\ - ((int(*)(PyObject *))_cffi_exports[1]) -#define _cffi_to_c_u8\ - ((int(*)(PyObject *))_cffi_exports[2]) -#define _cffi_to_c_i16 \ - ((int(*)(PyObject *))_cffi_exports[3]) -#define _cffi_to_c_u16 \ - ((int(*)(PyObject *))_cffi_exports[4]) -#define _cffi_to_c_i32 \ -
[pypy-commit] cffi cffi-1.0: Close branch, ready for merge
Author: Armin Rigo Branch: cffi-1.0 Changeset: r2048:05238b53dafb Date: 2015-05-18 18:22 +0200 http://bitbucket.org/cffi/cffi/changeset/05238b53dafb/ Log:Close branch, ready for merge ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] cffi default: Add a mostly empty "whatsnew.rst"
Author: Armin Rigo Branch: Changeset: r2050:4c7e3300ea09 Date: 2015-05-18 18:32 +0200 http://bitbucket.org/cffi/cffi/changeset/4c7e3300ea09/ Log:Add a mostly empty "whatsnew.rst" diff --git a/doc/source/index.rst b/doc/source/index.rst --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -9,6 +9,7 @@ .. toctree:: :maxdepth: 2 + whatsnew installation overview using diff --git a/doc/source/overview.rst b/doc/source/overview.rst --- a/doc/source/overview.rst +++ b/doc/source/overview.rst @@ -41,6 +41,8 @@ there, %s!\n"``. In general it is ``somestring.encode(myencoding)``. +.. _out-of-line-abi-level: + Out-of-line example (ABI level, out-of-line) @@ -49,7 +51,7 @@ massively reduces the import times, because it is slow to parse a large C header. It also allows you to do more detailed checkings during build-time without worrying about performance (e.g. calling -``cdef()`` several times with small pieces of declarations, based +``cdef()`` many times with small pieces of declarations, based on the version of libraries detected on the system). .. code-block:: python @@ -93,6 +95,7 @@ ) +.. _out-of-line-api-level: .. _real-example: Real example (API level, out-of-line) diff --git a/doc/source/whatsnew.rst b/doc/source/whatsnew.rst new file mode 100644 --- /dev/null +++ b/doc/source/whatsnew.rst @@ -0,0 +1,19 @@ +== +What's New +== + + +1.0.0 += + +* The main news item is out-of-line module generation: + + * `for ABI level`_, with ``ffi.dlopen()`` + + * `for API level`_, which used to be with ``ffi.verify()``, now deprecated + +* (this page will list what is new from all versions from 1.0.0 + forward.) + +.. _`for ABI level`: overview.html#out-of-line-abi-level +.. _`for API level`: overview.html#out-of-line-api-level ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] cffi default: hg merge cffi-1.0
Author: Armin Rigo Branch: Changeset: r2049:c870763046a6 Date: 2015-05-18 18:22 +0200 http://bitbucket.org/cffi/cffi/changeset/c870763046a6/ Log:hg merge cffi-1.0 diff too long, truncating to 2000 out of 19486 lines diff --git a/MANIFEST.in b/MANIFEST.in --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,6 @@ -recursive-include cffi *.py +recursive-include cffi *.py *.h recursive-include c *.c *.h *.asm *.py win64.obj recursive-include testing *.py recursive-include doc *.py *.rst Makefile *.bat -recursive-include demo py.cleanup *.py -include LICENSE setup_base.py +recursive-include demo py.cleanup *.py manual.c +include AUTHORS LICENSE setup.py setup_base.py diff --git a/TODO b/TODO deleted file mode 100644 --- a/TODO +++ /dev/null @@ -1,3 +0,0 @@ - - -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 @@ -72,6 +72,7 @@ # define PyText_FromString PyUnicode_FromString # define PyText_FromStringAndSize PyUnicode_FromStringAndSize # define PyText_InternInPlace PyUnicode_InternInPlace +# define PyText_InternFromString PyUnicode_InternFromString # define PyIntOrLong_Check PyLong_Check #else # define STR_OR_BYTES "str" @@ -85,6 +86,7 @@ # define PyText_FromString PyString_FromString # define PyText_FromStringAndSize PyString_FromStringAndSize # define PyText_InternInPlace PyString_InternInPlace +# define PyText_InternFromString PyString_InternFromString # define PyIntOrLong_Check(op) (PyInt_Check(op) || PyLong_Check(op)) #endif @@ -92,6 +94,7 @@ # define PyInt_FromLong PyLong_FromLong # define PyInt_FromSsize_t PyLong_FromSsize_t # define PyInt_AsSsize_t PyLong_AsSsize_t +# define PyInt_AsLong PyLong_AsLong #endif #if PY_MAJOR_VERSION >= 3 @@ -131,6 +134,7 @@ #define CT_IS_VOID_PTR 524288 #define CT_WITH_VAR_ARRAY 1048576 #define CT_IS_UNSIZED_CHAR_A 2097152 +#define CT_LAZY_FIELD_LIST4194304 #define CT_PRIMITIVE_ANY (CT_PRIMITIVE_SIGNED |\ CT_PRIMITIVE_UNSIGNED | \ CT_PRIMITIVE_CHAR | \ @@ -270,6 +274,8 @@ # include "wchar_helper.h" #endif +static PyObject *FFIError; + // static CTypeDescrObject * @@ -420,12 +426,21 @@ static PyObject * get_field_name(CTypeDescrObject *ct, CFieldObject *cf); /* forward */ +#define force_lazy_struct(ct) \ +((ct)->ct_stuff != NULL ? 1 : do_realize_lazy_struct(ct)) + +static int do_realize_lazy_struct(CTypeDescrObject *ct); +/* forward, implemented in realize_c_type.c */ + static PyObject *ctypeget_fields(CTypeDescrObject *ct, void *context) { if (ct->ct_flags & (CT_STRUCT | CT_UNION)) { if (!(ct->ct_flags & CT_IS_OPAQUE)) { CFieldObject *cf; -PyObject *res = PyList_New(0); +PyObject *res; +if (force_lazy_struct(ct) < 0) +return NULL; +res = PyList_New(0); if (res == NULL) return NULL; for (cf = (CFieldObject *)ct->ct_extra; @@ -1217,6 +1232,9 @@ { const char *expected; +if (force_lazy_struct(ct) < 0) +return -1; + if (ct->ct_flags & CT_UNION) { Py_ssize_t n = PyObject_Size(init); if (n < 0) @@ -1478,6 +1496,10 @@ if ((ct->ct_flags & (CT_PRIMITIVE_ANY|CT_STRUCT|CT_UNION)) && !(ct->ct_flags & CT_IS_OPAQUE)) { align = ct->ct_length; +if (align == -1 && (ct->ct_flags & CT_LAZY_FIELD_LIST)) { +force_lazy_struct(ct); +align = ct->ct_length; +} } else if (ct->ct_flags & (CT_POINTER|CT_FUNCTIONPTR)) { struct aligncheck_ptr { char x; char *y; }; @@ -1903,7 +1925,7 @@ } static PyObject * -new_array_type(CTypeDescrObject *ctptr, PyObject *lengthobj); /* forward */ +new_array_type(CTypeDescrObject *ctptr, Py_ssize_t length); /* forward */ static CTypeDescrObject * _cdata_getslicearg(CDataObject *cd, PySliceObject *slice, Py_ssize_t bounds[]) @@ -1968,7 +1990,7 @@ return NULL; if (ct->ct_stuff == NULL) { -ct->ct_stuff = new_array_type(ct, Py_None); +ct->ct_stuff = new_array_type(ct, -1); if (ct->ct_stuff == NULL) return NULL; } @@ -2220,18 +2242,26 @@ if (ct->ct_flags & CT_POINTER) ct = ct->ct_itemdescr; -if ((ct->ct_flags & (CT_STRUCT|CT_UNION)) && ct->ct_stuff != NULL) { -cf = (CFieldObject *)PyDict_GetItem(ct->ct_stuff, attr); -if (cf != NULL) { -/* read the field 'cf' */ -char *data = cd->c_data + cf->cf_offset; -if (cf->cf_bitshift == BS_REGULAR) -return convert_to_object(data, cf->cf_type); -else if (cf->cf_bitshift == BS_EMPTY_ARRAY) -return new_simple_cdata(data, -(CTypeDescrObject *)cf->cf_type
[pypy-commit] cffi default: Nicer to have these two paragraphs listed here too, even though they are from the same page
Author: Armin Rigo Branch: Changeset: r2051:8f2f87da79a3 Date: 2015-05-18 18:36 +0200 http://bitbucket.org/cffi/cffi/changeset/8f2f87da79a3/ Log:Nicer to have these two paragraphs listed here too, even though they are from the same page diff --git a/doc/source/index.rst b/doc/source/index.rst --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -6,6 +6,10 @@ convenient and reliable way to call compiled C code from Python using interface declarations written in C. +* Goals_ + + * `Comments and bugs`_ + .. toctree:: :maxdepth: 2 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-flags: add attribute flags to BaseConcreteArray
Author: mattip Branch: numpy-flags Changeset: r77377:a1a4c7af8ad6 Date: 2015-05-17 22:51 +0300 http://bitbucket.org/pypy/pypy/changeset/a1a4c7af8ad6/ Log:add attribute flags to BaseConcreteArray 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 @@ -22,6 +22,9 @@ """Base class for ndarrays and scalars (aka boxes).""" _attrs_ = [] +def get_flags(self): +return 0 + class W_NDimArray(W_NumpyObject): __metaclass__ = extendabletype @@ -134,6 +137,9 @@ def get_start(self): return self.implementation.start +def get_flags(self): +return self.implementation.flags + def ndims(self): return len(self.get_shape()) ndims._always_inline_ = True diff --git a/pypy/module/micronumpy/concrete.py b/pypy/module/micronumpy/concrete.py --- a/pypy/module/micronumpy/concrete.py +++ b/pypy/module/micronumpy/concrete.py @@ -7,11 +7,12 @@ from rpython.rtyper.lltypesystem import rffi, lltype, llmemory from pypy.module.micronumpy import support, loop, constants as NPY from pypy.module.micronumpy.base import convert_to_array, W_NDimArray, \ -ArrayArgumentException +ArrayArgumentException, W_NumpyObject from pypy.module.micronumpy.iterators import ArrayIter from pypy.module.micronumpy.strides import (Chunk, Chunks, NewAxisChunk, RecordChunk, calc_strides, calc_new_strides, shape_agreement, -calculate_broadcast_strides, calc_backstrides, calc_start) +calculate_broadcast_strides, calc_backstrides, calc_start, is_c_contiguous, +is_f_contiguous) from rpython.rlib.objectmodel import keepalive_until_here from rpython.rtyper.annlowlevel import cast_gcref_to_instance from pypy.interpreter.baseobjspace import W_Root @@ -19,7 +20,8 @@ class BaseConcreteArray(object): _immutable_fields_ = ['dtype?', 'storage', 'start', 'size', 'shape[*]', - 'strides[*]', 'backstrides[*]', 'order', 'gcstruct'] + 'strides[*]', 'backstrides[*]', 'order', 'gcstruct', + 'flags'] start = 0 parent = None flags = 0 @@ -443,6 +445,11 @@ ConcreteArrayNotOwning.__init__(self, shape, dtype, order, strides, backstrides, storage, start=start) self.gcstruct = gcstruct +self.flags = NPY.ARRAY_ALIGNED | NPY.ARRAY_WRITEABLE +if is_c_contiguous(self): +self.flags |= NPY.ARRAY_C_CONTIGUOUS +if is_f_contiguous(self): +self.flags |= NPY.ARRAY_F_CONTIGUOUS def __del__(self): if self.gcstruct: @@ -456,18 +463,39 @@ ConcreteArrayNotOwning.__init__(self, shape, dtype, order, strides, backstrides, storage, start) self.orig_base = orig_base +if isinstance(orig_base, W_NumpyObject): +self.flags = orig_base.get_flags() & NPY.ARRAY_ALIGNED +self.flags |= orig_base.get_flags() & NPY.ARRAY_WRITEABLE +else: +self.flags = 0 +if is_c_contiguous(self): +self.flags |= NPY.ARRAY_C_CONTIGUOUS +if is_f_contiguous(self): +self.flags |= NPY.ARRAY_F_CONTIGUOUS def base(self): return self.orig_base class ConcreteNonWritableArrayWithBase(ConcreteArrayWithBase): +def __init__(self, shape, dtype, order, strides, backstrides, storage, + orig_base, start=0): +ConcreteArrayWithBase.__init__(self, shape, dtype, order, strides, +backstrides, storage, orig_base, start) +self.flags &= ~ NPY.ARRAY_WRITEABLE + def descr_setitem(self, space, orig_array, w_index, w_value): raise OperationError(space.w_ValueError, space.wrap( "assignment destination is read-only")) class NonWritableArray(ConcreteArray): +def __init__(self, shape, dtype, order, strides, backstrides, + storage=lltype.nullptr(RAW_STORAGE), zero=True): +ConcreteArray.__init__(self, shape, dtype, order, strides, backstrides, +storage, zero) +self.flags &= ~ NPY.ARRAY_WRITEABLE + def descr_setitem(self, space, orig_array, w_index, w_value): raise OperationError(space.w_ValueError, space.wrap( "assignment destination is read-only")) @@ -491,6 +519,12 @@ self.size = support.product(shape) * self.dtype.elsize self.start = start self.orig_arr = orig_arr +self.flags = parent.flags & NPY.ARRAY_ALIGNED +self.flags |= parent.flags & NPY.ARRAY_WRITEABLE +if is_c_contiguous(self): +self.flags |= NPY.ARRAY_C_CONTIGUOUS +if is_f_contiguous(self): +self.flags |= NPY.ARRAY_F_CONTIGUOUS def base(self): return self.orig_arr @@ -538,6 +572,12 @@ return sort_array(self, space, w_axis, w_order) cla
[pypy-commit] pypy numpy-flags: cleanup, override __repr__
Author: mattip Branch: numpy-flags Changeset: r77380:be381bf59005 Date: 2015-05-18 22:38 +0300 http://bitbucket.org/pypy/pypy/changeset/be381bf59005/ Log:cleanup, override __repr__ diff --git a/pypy/module/micronumpy/flagsobj.py b/pypy/module/micronumpy/flagsobj.py --- a/pypy/module/micronumpy/flagsobj.py +++ b/pypy/module/micronumpy/flagsobj.py @@ -21,7 +21,6 @@ class W_FlagsObject(W_Root): def __init__(self, arr): -print 'initializing flag from',arr if arr: self.flags = arr.get_flags() else: @@ -112,6 +111,7 @@ __eq__ = interp2app(W_FlagsObject.descr_eq), __ne__ = interp2app(W_FlagsObject.descr_ne), __str__ = interp2app(W_FlagsObject.descr___str__), +__repr__ = interp2app(W_FlagsObject.descr___str__), contiguous = GetSetProperty(W_FlagsObject.descr_c_contiguous), c_contiguous = GetSetProperty(W_FlagsObject.descr_c_contiguous), ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-flags: pass tests in test_flagobj, add test for str(flags)
Author: mattip Branch: numpy-flags Changeset: r77378:d84dc304c027 Date: 2015-05-18 00:05 +0300 http://bitbucket.org/pypy/pypy/changeset/d84dc304c027/ Log:pass tests in test_flagobj, add test for str(flags) 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 @@ -143,6 +143,10 @@ def get_scalar_value(self): return self +def get_flags(self): +return (NPY.ARRAY_C_CONTIGUOUS | NPY.ARRAY_F_CONTIGUOUS | +NPY.ARRAY_WRITEABLE | NPY.ARRAY_OWNDATA) + def item(self, space): return self.get_dtype(space).itemtype.to_builtin_type(space, self) diff --git a/pypy/module/micronumpy/flagsobj.py b/pypy/module/micronumpy/flagsobj.py --- a/pypy/module/micronumpy/flagsobj.py +++ b/pypy/module/micronumpy/flagsobj.py @@ -1,4 +1,5 @@ from rpython.rlib import jit +from rpython.rlib.rstring import StringBuilder from pypy.interpreter.baseobjspace import W_Root from pypy.interpreter.error import OperationError @@ -13,54 +14,50 @@ def clear_flags(arr, flags): arr.flags &= ~flags -def _update_contiguous_flags(arr): -is_c_contig = is_c_contiguous(arr) -if is_c_contig: -enable_flags(arr, NPY.ARRAY_C_CONTIGUOUS) -else: -clear_flags(arr, NPY.ARRAY_C_CONTIGUOUS) - -is_f_contig = is_f_contiguous(arr) -if is_f_contig: -enable_flags(arr, NPY.ARRAY_F_CONTIGUOUS) -else: -clear_flags(arr, NPY.ARRAY_F_CONTIGUOUS) - +def get_tf_str(flags, key): +if flags & key: +return 'True' +return 'False' class W_FlagsObject(W_Root): def __init__(self, arr): -self.flags = 0 +print 'initializing flag from',arr +if arr: +self.flags = arr.get_flags() +else: +self.flags = (NPY.ARRAY_C_CONTIGUOUS | NPY.ARRAY_F_CONTIGUOUS | + NPY.ARRAY_OWNDATA | NPY.ARRAY_ALIGNED) def descr__new__(space, w_subtype): self = space.allocate_instance(W_FlagsObject, w_subtype) W_FlagsObject.__init__(self, None) return self -def descr_get_contiguous(self, space): -return space.w_True +def descr_c_contiguous(self, space): +return space.wrap(bool(self.flags & NPY.ARRAY_C_CONTIGUOUS)) -def descr_get_fortran(self, space): -return space.w_False +def descr_f_contiguous(self, space): +return space.wrap(bool(self.flags & NPY.ARRAY_F_CONTIGUOUS)) def descr_get_writeable(self, space): -return space.w_True +return space.wrap(bool(self.flags & NPY.ARRAY_WRITEABLE)) def descr_get_fnc(self, space): -return space.wrap( -space.is_true(self.descr_get_fortran(space)) and not -space.is_true(self.descr_get_contiguous(space))) +return space.wrap(bool( +self.flags & NPY.ARRAY_F_CONTIGUOUS and not +self.flags & NPY.ARRAY_C_CONTIGUOUS )) def descr_get_forc(self, space): -return space.wrap( -space.is_true(self.descr_get_fortran(space)) or -space.is_true(self.descr_get_contiguous(space))) +return space.wrap(bool( +self.flags & NPY.ARRAY_F_CONTIGUOUS or +self.flags & NPY.ARRAY_C_CONTIGUOUS )) def descr_getitem(self, space, w_item): key = space.str_w(w_item) if key == "C" or key == "CONTIGUOUS" or key == "C_CONTIGUOUS": -return self.descr_get_contiguous(space) +return self.descr_c_contiguous(space) if key == "F" or key == "FORTRAN" or key == "F_CONTIGUOUS": -return self.descr_get_fortran(space) +return self.descr_f_contiguous(space) if key == "W" or key == "WRITEABLE": return self.descr_get_writeable(space) if key == "FNC": @@ -85,6 +82,22 @@ def descr_ne(self, space, w_other): return space.wrap(not self.eq(space, w_other)) +def descr___str__(self, space): +s = StringBuilder() +s.append(' C_CONTIGUOUS : ') +s.append(get_tf_str(self.flags, NPY.ARRAY_C_CONTIGUOUS)) +s.append('\n F_CONTIGUOUS : ') +s.append(get_tf_str(self.flags, NPY.ARRAY_F_CONTIGUOUS)) +s.append('\n OWNDATA : ') +s.append(get_tf_str(self.flags, NPY.ARRAY_OWNDATA)) +s.append('\n WRITEABLE : ') +s.append(get_tf_str(self.flags, NPY.ARRAY_WRITEABLE)) +s.append('\n ALIGNED : ') +s.append(get_tf_str(self.flags, NPY.ARRAY_ALIGNED)) +s.append('\n UPDATEIFCOPY : ') +s.append(get_tf_str(self.flags, NPY.ARRAY_UPDATEIFCOPY)) +return space.wrap(s.build()) + W_FlagsObject.typedef = TypeDef("numpy.flagsobj", __new__ = interp2app(W_FlagsObject.descr__new__.im_func), @@ -92,11 +105,12 @@ __setitem__ = interp2app(W_FlagsObject.descr_setitem), __eq__ = interp2app(W_FlagsObject.descr_eq), __ne__ = interp2app(W_FlagsObjec
[pypy-commit] pypy numpy-flags: add more properties
Author: mattip Branch: numpy-flags Changeset: r77379:5285b5a3b37e Date: 2015-05-18 20:24 +0300 http://bitbucket.org/pypy/pypy/changeset/5285b5a3b37e/ Log:add more properties diff --git a/pypy/module/micronumpy/flagsobj.py b/pypy/module/micronumpy/flagsobj.py --- a/pypy/module/micronumpy/flagsobj.py +++ b/pypy/module/micronumpy/flagsobj.py @@ -42,6 +42,12 @@ def descr_get_writeable(self, space): return space.wrap(bool(self.flags & NPY.ARRAY_WRITEABLE)) +def descr_get_owndata(self, space): +return space.wrap(bool(self.flags & NPY.ARRAY_OWNDATA)) + +def descr_get_aligned(self, space): +return space.wrap(bool(self.flags & NPY.ARRAY_ALIGNED)) + def descr_get_fnc(self, space): return space.wrap(bool( self.flags & NPY.ARRAY_F_CONTIGUOUS and not @@ -112,6 +118,8 @@ f_contiguous = GetSetProperty(W_FlagsObject.descr_f_contiguous), fortran = GetSetProperty(W_FlagsObject.descr_f_contiguous), writeable = GetSetProperty(W_FlagsObject.descr_get_writeable), +owndata = GetSetProperty(W_FlagsObject.descr_get_owndata), +aligned = GetSetProperty(W_FlagsObject.descr_get_aligned), fnc = GetSetProperty(W_FlagsObject.descr_get_fnc), forc = GetSetProperty(W_FlagsObject.descr_get_forc), ) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy more-rposix: Restore dont_look_inside annotation
Author: Amaury Forgeot d'Arc Branch: more-rposix Changeset: r77381:804e2318f544 Date: 2015-05-18 23:13 +0200 http://bitbucket.org/pypy/pypy/changeset/804e2318f544/ Log:Restore dont_look_inside annotation diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py --- a/rpython/rlib/rposix.py +++ b/rpython/rlib/rposix.py @@ -779,6 +779,7 @@ save_err=rffi.RFFI_SAVE_ERRNO) @replace_os_function('fork') +@jit.dont_look_inside def fork(): # NB. keep forkpty() up-to-date, too ofs = debug.debug_offset() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-flags: close branch to be merged
Author: mattip Branch: numpy-flags Changeset: r77383:2bf506948344 Date: 2015-05-18 23:45 +0300 http://bitbucket.org/pypy/pypy/changeset/2bf506948344/ Log:close branch to be merged ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge numpy-flags which completes the ndarray.flags property
Author: mattip Branch: Changeset: r77384:cf50e5142096 Date: 2015-05-18 23:46 +0300 http://bitbucket.org/pypy/pypy/changeset/cf50e5142096/ Log:merge numpy-flags which completes the ndarray.flags property diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -109,3 +109,8 @@ branch pythonoptimize-env Implement PYTHONOPTIMIZE environment variable, fixing issue #2044 + +.. branch: numpy-flags + +branch numpy-flags +Finish implementation of ndarray.flags, including str() and repr() 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 @@ -22,6 +22,9 @@ """Base class for ndarrays and scalars (aka boxes).""" _attrs_ = [] +def get_flags(self): +return 0 + class W_NDimArray(W_NumpyObject): __metaclass__ = extendabletype @@ -134,6 +137,9 @@ def get_start(self): return self.implementation.start +def get_flags(self): +return self.implementation.flags + def ndims(self): return len(self.get_shape()) ndims._always_inline_ = True 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 @@ -143,6 +143,10 @@ def get_scalar_value(self): return self +def get_flags(self): +return (NPY.ARRAY_C_CONTIGUOUS | NPY.ARRAY_F_CONTIGUOUS | +NPY.ARRAY_WRITEABLE | NPY.ARRAY_OWNDATA) + def item(self, space): return self.get_dtype(space).itemtype.to_builtin_type(space, self) diff --git a/pypy/module/micronumpy/concrete.py b/pypy/module/micronumpy/concrete.py --- a/pypy/module/micronumpy/concrete.py +++ b/pypy/module/micronumpy/concrete.py @@ -7,11 +7,12 @@ from rpython.rtyper.lltypesystem import rffi, lltype, llmemory from pypy.module.micronumpy import support, loop, constants as NPY from pypy.module.micronumpy.base import convert_to_array, W_NDimArray, \ -ArrayArgumentException +ArrayArgumentException, W_NumpyObject from pypy.module.micronumpy.iterators import ArrayIter from pypy.module.micronumpy.strides import (Chunk, Chunks, NewAxisChunk, RecordChunk, calc_strides, calc_new_strides, shape_agreement, -calculate_broadcast_strides, calc_backstrides, calc_start) +calculate_broadcast_strides, calc_backstrides, calc_start, is_c_contiguous, +is_f_contiguous) from rpython.rlib.objectmodel import keepalive_until_here from rpython.rtyper.annlowlevel import cast_gcref_to_instance from pypy.interpreter.baseobjspace import W_Root @@ -19,7 +20,8 @@ class BaseConcreteArray(object): _immutable_fields_ = ['dtype?', 'storage', 'start', 'size', 'shape[*]', - 'strides[*]', 'backstrides[*]', 'order', 'gcstruct'] + 'strides[*]', 'backstrides[*]', 'order', 'gcstruct', + 'flags'] start = 0 parent = None flags = 0 @@ -443,6 +445,11 @@ ConcreteArrayNotOwning.__init__(self, shape, dtype, order, strides, backstrides, storage, start=start) self.gcstruct = gcstruct +self.flags = NPY.ARRAY_ALIGNED | NPY.ARRAY_WRITEABLE +if is_c_contiguous(self): +self.flags |= NPY.ARRAY_C_CONTIGUOUS +if is_f_contiguous(self): +self.flags |= NPY.ARRAY_F_CONTIGUOUS def __del__(self): if self.gcstruct: @@ -456,18 +463,39 @@ ConcreteArrayNotOwning.__init__(self, shape, dtype, order, strides, backstrides, storage, start) self.orig_base = orig_base +if isinstance(orig_base, W_NumpyObject): +self.flags = orig_base.get_flags() & NPY.ARRAY_ALIGNED +self.flags |= orig_base.get_flags() & NPY.ARRAY_WRITEABLE +else: +self.flags = 0 +if is_c_contiguous(self): +self.flags |= NPY.ARRAY_C_CONTIGUOUS +if is_f_contiguous(self): +self.flags |= NPY.ARRAY_F_CONTIGUOUS def base(self): return self.orig_base class ConcreteNonWritableArrayWithBase(ConcreteArrayWithBase): +def __init__(self, shape, dtype, order, strides, backstrides, storage, + orig_base, start=0): +ConcreteArrayWithBase.__init__(self, shape, dtype, order, strides, +backstrides, storage, orig_base, start) +self.flags &= ~ NPY.ARRAY_WRITEABLE + def descr_setitem(self, space, orig_array, w_index, w_value): raise OperationError(space.w_ValueError, space.wrap( "assignment destination is read-only")) class NonWritableArray(ConcreteArray): +def __init__(self, shape, dtype, order, strides, backstrides, + storage=lltype.nullptr(RAW_STORAGE), zero=True): +ConcreteArray.__init__(self, shape, dtype, o
[pypy-commit] pypy numpy-flags: document branch
Author: mattip Branch: numpy-flags Changeset: r77382:092e35020752 Date: 2015-05-18 23:44 +0300 http://bitbucket.org/pypy/pypy/changeset/092e35020752/ Log:document branch diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -109,3 +109,8 @@ branch pythonoptimize-env Implement PYTHONOPTIMIZE environment variable, fixing issue #2044 + +.. branch: numpy-flags + +branch numpy-flags +Finish implementation of ndarray.flags, including str() and repr() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: rework failing tests
Author: mattip Branch: Changeset: r77385:bcc0d42ab17f Date: 2015-05-19 00:08 +0300 http://bitbucket.org/pypy/pypy/changeset/bcc0d42ab17f/ Log:rework failing tests diff --git a/pypy/module/micronumpy/test/test_iterators.py b/pypy/module/micronumpy/test/test_iterators.py --- a/pypy/module/micronumpy/test/test_iterators.py +++ b/pypy/module/micronumpy/test/test_iterators.py @@ -1,5 +1,7 @@ from pypy.module.micronumpy import support from pypy.module.micronumpy.iterators import ArrayIter +from pypy.module.micronumpy.strides import is_c_contiguous, is_f_contiguous +from pypy.module.micronumpy import constants as NPY class MockArray(object): @@ -12,6 +14,10 @@ self.shape = shape self.strides = strides self.start = start +if is_c_contiguous(self): +self.flags |= NPY.ARRAY_C_CONTIGUOUS +if is_f_contiguous(self): +self.flags |= NPY.ARRAY_F_CONTIGUOUS def get_shape(self): return self.shape 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 @@ -258,17 +258,6 @@ # test uninitialized value crash? assert len(str(a)) > 0 -import sys -for order in [False, True, 'C', 'F']: -a = ndarray.__new__(ndarray, (2, 3), float, order=order) -assert a.shape == (2, 3) -if order in [True, 'F'] and '__pypy__' not in sys.builtin_module_names: -assert a.flags['F'] -assert not a.flags['C'] -else: -assert a.flags['C'] -assert not a.flags['F'] - x = array([[0, 2], [1, 1], [2, 0]]) y = array(x.T, dtype=float) assert (y == x.T).all() @@ -2588,6 +2577,18 @@ assert a[0][1][1] == 13 assert a[1][2][1] == 15 +def test_create_order(self): +import sys, numpy as np +for order in [False, True, 'C', 'F']: +a = np.empty((2, 3), float, order=order) +assert a.shape == (2, 3) +if order in [True, 'F'] and '__pypy__' not in sys.builtin_module_names: +assert a.flags['F'] +assert not a.flags['C'] +else: +assert a.flags['C'], "flags['C'] False for %r" % order +assert not a.flags['F'] + def test_setitem_slice(self): import numpy a = numpy.zeros((3, 4)) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy.org extradoc: update the values
Author: Armin Rigo Branch: extradoc Changeset: r608:b5af029050ff Date: 2015-05-18 23:26 +0200 http://bitbucket.org/pypy/pypy.org/changeset/b5af029050ff/ Log:update the values diff --git a/don1.html b/don1.html --- a/don1.html +++ b/don1.html @@ -9,13 +9,13 @@ $(function() { $("#progressbar").progressbar({ - value: 56.5 + value: 56.6 }); }); - $59331 of $105000 (56.5%) + $59426 of $105000 (56.6%) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] cffi default: Mention two MSVC compilers
Author: Armin Rigo Branch: Changeset: r2052:66962fed48b1 Date: 2015-05-18 23:40 +0200 http://bitbucket.org/cffi/cffi/changeset/66962fed48b1/ Log:Mention two MSVC compilers diff --git a/doc/source/installation.rst b/doc/source/installation.rst --- a/doc/source/installation.rst +++ b/doc/source/installation.rst @@ -132,12 +132,22 @@ .. _here: http://superuser.com/questions/259278/python-2-6-1-pycrypto-2-3-pypi-package-broken-pipe-during-build +Windows (regular 32-bit) + + +Win32 works and is tested at least each official release. + +The recommended C compiler compatible with Python 2.7 is this one: +http://www.microsoft.com/en-us/download/details.aspx?id=44266 + +For Python 3.4 and beyond: +https://www.visualstudio.com/en-us/downloads/visual-studio-2015-ctp-vs + + Windows 64 ++ -Win32 works and is tested at least each official release. - -Status: Win64 received very basic testing and we applied a few essential +Win64 received very basic testing and we applied a few essential fixes in cffi 0.7. Please report any other issue. Note as usual that this is only about running the 64-bit version of ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] cffi default: Skip this test on pypy (it's done already pre-translated)
Author: Armin Rigo Branch: Changeset: r2053:8e5609919d2e Date: 2015-05-18 23:55 +0200 http://bitbucket.org/cffi/cffi/changeset/8e5609919d2e/ Log:Skip this test on pypy (it's done already pre-translated) diff --git a/testing/cffi1/test_parse_c_type.py b/testing/cffi1/test_parse_c_type.py --- a/testing/cffi1/test_parse_c_type.py +++ b/testing/cffi1/test_parse_c_type.py @@ -2,6 +2,9 @@ import cffi from cffi import cffi_opcode +if '__pypy__' in sys.builtin_module_names: +py.test.skip("not available on pypy") + cffi_dir = os.path.dirname(cffi_opcode.__file__) r_macro = re.compile(r"#define \w+[(][^\n]*|#include [^\n]*") ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cffi-1.0: Make the cffi tests pass on a translated pypy
Author: Armin Rigo Branch: cffi-1.0 Changeset: r77386:04b1ea6dd195 Date: 2015-05-18 23:56 +0200 http://bitbucket.org/pypy/pypy/changeset/04b1ea6dd195/ Log:Make the cffi tests pass on a translated pypy diff --git a/lib_pypy/cffi/testing/__init__.py b/lib_pypy/cffi/testing/__init__.py new file mode 100644 diff --git a/lib_pypy/cffi/testing/udir.py b/lib_pypy/cffi/testing/udir.py new file mode 100644 --- /dev/null +++ b/lib_pypy/cffi/testing/udir.py @@ -0,0 +1,3 @@ +import py + +udir = py.path.local.make_numbered_dir(prefix = 'ffi-') diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_parse_c_type.py b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_parse_c_type.py --- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_parse_c_type.py +++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_parse_c_type.py @@ -3,6 +3,9 @@ import cffi from cffi import cffi_opcode +if '__pypy__' in sys.builtin_module_names: +py.test.skip("not available on pypy") + cffi_dir = os.path.dirname(cffi_opcode.__file__) r_macro = re.compile(r"#define \w+[(][^\n]*|#include [^\n]*") diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_egg_version.py b/pypy/module/test_lib_pypy/cffi_tests/test_egg_version.py --- a/pypy/module/test_lib_pypy/cffi_tests/test_egg_version.py +++ b/pypy/module/test_lib_pypy/cffi_tests/test_egg_version.py @@ -5,7 +5,7 @@ import cffi import pypy -egg_info = py.path.local(pypy.__file__) / '../../lib_pypy/cffi.egg-info' +egg_info = py.path.local(pypy.__file__)/'../../lib_pypy/cffi.egg-info/PKG-INFO' def test_egg_version(): info = Parser().parsestr(egg_info.read()) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy fix-result-types: don't use find_binop_result_dtype() in W_Ufunc2.call()
Author: Ronan Lamy Branch: fix-result-types Changeset: r77387:432c15e49a7e Date: 2015-05-17 22:23 +0100 http://bitbucket.org/pypy/pypy/changeset/432c15e49a7e/ Log:don't use find_binop_result_dtype() in W_Ufunc2.call() 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 @@ -288,7 +288,7 @@ types += ['g', 'G'] a = array([True], '?') for t in types: -assert (a + array([0], t)).dtype is dtype(t) +assert (a + array([0], t)).dtype == dtype(t) def test_binop_types(self): from numpy import array, dtype @@ -312,7 +312,7 @@ for d1, d2, dout in tests: # make a failed test print helpful info d3 = (array([1], d1) + array([1], d2)).dtype -assert (d1, d2) == (d1, d2) and d3 is dtype(dout) +assert (d1, d2) == (d1, d2) and d3 == dtype(dout) def test_add(self): import numpy as np 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 @@ -613,7 +613,7 @@ w_rdtype = w_ldtype elif w_lhs.is_scalar() and not w_rhs.is_scalar(): w_ldtype = w_rdtype -calc_dtype, res_dtype, func = self.find_specialization(space, w_ldtype, w_rdtype, out, casting) +calc_dtype, dt_out, func = self.find_specialization(space, w_ldtype, w_rdtype, out, casting) if (isinstance(w_lhs, W_GenericBox) and isinstance(w_rhs, W_GenericBox) and out is None): return self.call_scalar(space, w_lhs, w_rhs, calc_dtype) @@ -627,7 +627,7 @@ new_shape = shape_agreement(space, new_shape, out, broadcast_down=False) w_highpriority, out_subtype = array_priority(space, w_lhs, w_rhs) if out is None: -w_res = W_NDimArray.from_shape(space, new_shape, res_dtype, +w_res = W_NDimArray.from_shape(space, new_shape, dt_out, w_instance=out_subtype) else: w_res = out @@ -648,26 +648,62 @@ return w_val def find_specialization(self, space, l_dtype, r_dtype, out, casting): -calc_dtype = find_binop_result_dtype(space, -l_dtype, r_dtype, -promote_to_float=self.promote_to_float, -promote_bools=self.promote_bools) -if (self.int_only and (not (l_dtype.is_int() or l_dtype.is_object()) or - not (r_dtype.is_int() or r_dtype.is_object()) or - not (calc_dtype.is_int() or calc_dtype.is_object())) or -not self.allow_bool and (l_dtype.is_bool() or +if (not self.allow_bool and (l_dtype.is_bool() or r_dtype.is_bool()) or not self.allow_complex and (l_dtype.is_complex() or r_dtype.is_complex())): raise oefmt(space.w_TypeError, "ufunc '%s' not supported for the input types", self.name) -if out is not None: -calc_dtype = out.get_dtype() +dt_in, dt_out = self._calc_dtype(space, l_dtype, r_dtype, out, casting) +return dt_in, dt_out, self.func + +def _calc_dtype(self, space, l_dtype, r_dtype, out=None, casting='unsafe'): +use_min_scalar = False +if l_dtype.is_object() or r_dtype.is_object(): +return l_dtype, l_dtype +in_casting = safe_casting_mode(casting) +for dt_in, dt_out in self.allowed_types(space): +if use_min_scalar: +if not can_cast_array(space, w_arg, dt_in, in_casting): +continue +else: +if not (can_cast_type(space, l_dtype, dt_in, in_casting) and +can_cast_type(space, r_dtype, dt_in, in_casting)): +continue +if out is not None: +res_dtype = out.get_dtype() +if not can_cast_type(space, dt_out, res_dtype, casting): +continue +return dt_in, dt_out + +else: +raise oefmt(space.w_TypeError, +"No loop matching the specified signature was found " +"for ufunc %s", self.name) + +def allowed_types(self, space): +dtypes = [] +cache = get_dtype_cache(space) +if not self.promote_bools and not self.promote_to_float: +dtypes.append((cache.w_booldtype, cache.w_booldtype)) +if not self.promote_to_float: +for dt in cache.integer_dtypes: +dtypes.append((dt, dt)) +if not self.int_only: +for dt in cache.float_dtypes: +dtypes.append((dt, dt)) +for dt in cache.complex_dtypes: +
[pypy-commit] pypy fix-result-types: fix for comparison ufuncs
Author: Ronan Lamy Branch: fix-result-types Changeset: r77388:4fddce12b069 Date: 2015-05-19 02:59 +0100 http://bitbucket.org/pypy/pypy/changeset/4fddce12b069/ Log:fix for comparison ufuncs 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 @@ -20,7 +20,7 @@ from pypy.module.micronumpy.support import (_parse_signature, product, get_storage_as_int, is_rhs_priority_higher) from .casting import ( -find_unaryop_result_dtype, find_binop_result_dtype, can_cast_type) +find_unaryop_result_dtype, can_cast_type, find_result_type) from .boxes import W_GenericBox, W_ObjectBox def done_if_true(dtype, val): @@ -654,6 +654,11 @@ r_dtype.is_complex())): raise oefmt(space.w_TypeError, "ufunc '%s' not supported for the input types", self.name) +if self.bool_result: +# XXX: should actually pass the arrays +dtype = find_result_type(space, [], [l_dtype, r_dtype]) +bool_dtype = get_dtype_cache(space).w_booldtype +return dtype, bool_dtype, self.func dt_in, dt_out = self._calc_dtype(space, l_dtype, r_dtype, out, casting) return dt_in, dt_out, self.func ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit