[Cython] PEP 448 implemented: unpacking generalisations

Stefan Behnel stefan_ml at behnel.de
Fri May 15 14:13:25 CEST 2015


Hi,

I implemented PEP 448 in the latest master branch. It extends Python's
unpacking syntax to allow things like

    d = {**kw, 1: 2, 3: 4, **morekw}

    s = {1, 2, 3, *args, *extra}

    t = (1, *x, *y, *z)

    head, *tail = [*x, *y]

    func(**kw1, **kw2)

https://www.python.org/dev/peps/pep-0448/

For function calls, you'll get an error for duplicate keys, but not for
dicts and sets, where the last entry prevails.

I'd be happy to see some feedback. The code it generates is already pretty
good and I've added a whole bunch of tests, but it definitely needs some
user side testing. If you find anything that doesn't work, please send a
pull request that adds a test to one of the pep448_*.pyx test files in the
tests directory.

Stefan


More information about the cython-devel mailing list