From e368cf9b967c644dfb59c6261ad1e25cf25f917f Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Mon, 17 May 2010 08:38:00 +0200 Subject: [PATCH] do not optimise len(str) as it doesn't map to a simple C-API function, small cleanup --- Cython/Compiler/Optimize.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index bfbc32c3..3ec67623 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -1506,7 +1506,6 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): _map_to_capi_len_function = { Builtin.unicode_type : "PyUnicode_GET_SIZE", - Builtin.str_type : "Py_SIZE", # works in Py2 and Py3 Builtin.bytes_type : "PyBytes_GET_SIZE", Builtin.list_type : "PyList_GET_SIZE", Builtin.tuple_type : "PyTuple_GET_SIZE", @@ -1535,9 +1534,8 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): cfunc_name = self._map_to_capi_len_function(arg.type) if cfunc_name is None: return node - if not arg.is_literal: - arg = arg.as_none_safe_node( - "object of type 'NoneType' has no len()") + arg = arg.as_none_safe_node( + "object of type 'NoneType' has no len()") new_node = ExprNodes.PythonCapiCallNode( node.pos, cfunc_name, self.PyObject_Size_func_type, args = [arg], -- 2.26.2