[Cython] weird code in argument unpacking (memoryview related?)

Stefan Behnel stefan_ml at behnel.de
Fri Mar 30 13:19:37 CEST 2012


this code in Nodes.py around line 3950, at the end of the DefNodeWrapper's
method generate_keyword_unpacking_code(), was added as part of the memory
view changes, back in July last year:

        # convert arg values to their final type and assign them
        for i, arg in enumerate(all_args):
            if arg.default and not arg.type.is_pyobject:
                code.putln("if (values[%d]) {" % i)
            if arg.default and not arg.type.is_pyobject:
                code.putln('} else {')
                    "%s = %s;" % (
                if arg.type.is_memoryviewslice:

By being overly complicated, it hides rather well what it's actually meant
to achieve. It doesn't do at all what its comment says and also refers to
the default value of the argument, which is already assigned way before
this place in the code. Therefore, I'd be surprised if it generated
anything but dead C code, because the case that "values[i]" is NULL should
never happen.

Mark, could you comment on this? Is this just a left-over from a broken
merge or something?


More information about the cython-devel mailing list