Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #121 from scoder/_minor_fused_cleanup

minor fused cleanups
  • Loading branch information...
commit de3f9a33c050dc41d983922fa99add3f8efde12e 2 parents 761fbb3 + b1ece04
@markflorisson authored
Showing with 11 additions and 24 deletions.
  1. +10 −24 Cython/Compiler/FusedNode.py
  2. +1 −0  Cython/Compiler/Symtab.py
View
34 Cython/Compiler/FusedNode.py
@@ -238,19 +238,11 @@ def _fused_instance_checks(self, normal_types, pyx_code, env):
for specialized_type in normal_types:
# all_numeric = all_numeric and specialized_type.is_numeric
py_type_name = specialized_type.py_type_name()
-
- # in the case of long, unicode or bytes we need to instance
- # check for long_, unicode_, bytes_ (long = long is no longer
- # valid code with control flow analysis)
- specialized_check_name = py_type_name
- if py_type_name in ('long', 'unicode', 'bytes'):
- specialized_check_name += '_'
-
specialized_type_name = specialized_type.specialization_string
pyx_code.context.update(locals())
pyx_code.put_chunk(
u"""
- {{if_}} isinstance(arg, {{specialized_check_name}}):
+ {{if_}} isinstance(arg, {{py_type_name}}):
dest_sig[{{dest_sig_idx}}] = '{{specialized_type_name}}'
""")
if_ = 'elif'
@@ -539,17 +531,7 @@ def make_fused_cpdef(self, orig_py_func, env, is_def):
pyx_code.put_chunk(
u"""
def __pyx_fused_cpdef(signatures, args, kwargs, defaults):
- import sys
- if sys.version_info >= (3, 0):
- long_ = int
- unicode_ = str
- bytes_ = bytes
- else:
- long_ = long
- unicode_ = unicode
- bytes_ = str
-
- dest_sig = [None] * {{n_fused}}
+ dest_sig = [{{for _ in range(n_fused)}}None,{{endfor}}]
if kwargs is None:
kwargs = {}
@@ -594,10 +576,14 @@ def __pyx_fused_cpdef(signatures, args, kwargs, defaults):
u"""
candidates = []
for sig in signatures:
- match_found = filter(None, dest_sig)
+ match_found = False
for src_type, dst_type in zip(sig.strip('()').split(', '), dest_sig):
- if dst_type is not None and match_found:
- match_found = src_type == dst_type
+ if dst_type is not None:
+ if src_type == dst_type:
+ match_found = True
+ else:
+ match_found = False
+ break
if match_found:
candidates.append(sig)
@@ -781,4 +767,4 @@ def generate_execution_code(self, code):
def annotate(self, code):
for stat in self.stats:
- stat.annotate(code)
+ stat.annotate(code)
View
1  Cython/Compiler/Symtab.py
@@ -183,6 +183,7 @@ class Entry(object):
fused_cfunction = None
is_fused_specialized = False
utility_code_definition = None
+ needs_property = False
in_with_gil_block = 0
from_cython_utility_code = None
error_on_uninitialized = False
Please sign in to comment.
Something went wrong with that request. Please try again.