Commit 486421f6 authored by Stefan Behnel's avatar Stefan Behnel

Merge branch 'master' into readonly_buffers

parents 3efa9f9a 969dbad1
......@@ -8,6 +8,10 @@ Cython Changelog
Features added
--------------
* When compiling with gcc, the module init function is now tuned for small
code size instead of whatever compile flags were provided externally.
(Github issue #2102)
* Cdef classes can now multiply inherit from ordinary Python classes.
(The primary base must still be a c class, possibly ``object``, and
the other bases must *not* be cdef classes.)
......
......@@ -7765,10 +7765,10 @@ class TupleNode(SequenceNode):
if self.mult_factor or not self.args:
return tuple_type
arg_types = [arg.infer_type(env) for arg in self.args]
if any(type.is_pyobject or type.is_unspecified or type.is_fused for type in arg_types):
if any(type.is_pyobject or type.is_memoryviewslice or type.is_unspecified or type.is_fused
for type in arg_types):
return tuple_type
else:
return env.declare_tuple_type(self.pos, arg_types).type
return env.declare_tuple_type(self.pos, arg_types).type
def analyse_types(self, env, skip_children=False):
if len(self.args) == 0:
......@@ -7782,7 +7782,8 @@ class TupleNode(SequenceNode):
arg.starred_expr_allowed_here = True
self.args[i] = arg.analyse_types(env)
if (not self.mult_factor and
not any((arg.is_starred or arg.type.is_pyobject or arg.type.is_fused) for arg in self.args)):
not any((arg.is_starred or arg.type.is_pyobject or arg.type.is_memoryviewslice or arg.type.is_fused)
for arg in self.args)):
self.type = env.declare_tuple_type(self.pos, (arg.type for arg in self.args)).type
self.is_temp = 1
return self
......
......@@ -2279,10 +2279,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
header2 = "__Pyx_PyMODINIT_FUNC init%s(void)" % env.module_name
header3 = "__Pyx_PyMODINIT_FUNC %s(void)" % self.mod_init_func_cname('PyInit', env)
code.putln("#if PY_MAJOR_VERSION < 3")
code.putln("%s; /*proto*/" % header2)
# Optimise for small code size as the module init function is only executed once.
code.putln("%s CYTHON_SMALL_CODE; /*proto*/" % header2)
code.putln(header2)
code.putln("#else")
code.putln("%s; /*proto*/" % header3)
code.putln("%s CYTHON_SMALL_CODE; /*proto*/" % header3)
code.putln(header3)
# CPython 3.5+ supports multi-phase module initialisation (gives access to __spec__, __file__, etc.)
......@@ -2296,7 +2297,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("")
# main module init code lives in Py_mod_exec function, not in PyInit function
code.putln("static int %s(PyObject *%s)" % (
code.putln("static int %s(PyObject *%s) CYTHON_SMALL_CODE " % (
self.mod_init_func_cname(Naming.pymodule_exec_func_cname, env),
Naming.pymodinit_module_arg))
code.putln("#endif") # PEP489
......
......@@ -751,7 +751,7 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha
__Pyx_BufFmt_RaiseUnexpectedChar('Z');
return NULL;
}
/* fall through */
CYTHON_FALLTHROUGH;
case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
case 'l': case 'L': case 'q': case 'Q':
case 'f': case 'd': case 'g':
......@@ -765,7 +765,7 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha
++ts;
break;
}
/* fall through */
CYTHON_FALLTHROUGH;
case 's':
/* 's' or new type (cannot be added to current pool) */
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
......
......@@ -665,6 +665,16 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
#define CYTHON_SMALL_CODE
#elif defined(__GNUC__)
#define CYTHON_SMALL_CODE __attribute__((optimize("Os")))
#else
#define CYTHON_SMALL_CODE
#endif
#endif
/////////////// FastTypeChecks.proto ///////////////
......
;;; cython-mode.el --- Major mode for editing Cython files
;; License: Apache-2.0
;;; Commentary:
;; This should work with python-mode.el as well as either the new
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment