[Python-ideas] New 3.x restriction on number of keyword arguments

M.-A. Lemburg mal at egenix.com
Fri Oct 22 20:35:18 CEST 2010

Cesare Di Mauro wrote:
> 2010/10/21 Benjamin Peterson <benjamin at python.org>
>> Georg Brandl <g.brandl at ...> writes:
>>> You must be talking of a different restriction.
>> I assumed Raymond was talking about calling a function with > 255 args.
> I think that having max 255 args and 255 kwargs is a good and reasonable
> limit which we can live on, and helps the virtual machine implementation
> (and implementors :P).
> Python won't lose its "power" and "generality" if one VM (albeit the
> "mainstream" / "official" one) have some limits.
> We already have some other ones, such as max 65536 constants, names, globals
> and locals. Another one is the maximum 20 blocks for code object. Who thinks
> that such limits must be removed?
> I think that having more than 255 arguments for a function call is a very
> rare case for which a workaround (may be passing a tuple/list or a
> dictionary) can be a better solution than having to introduce a brand new
> opcode to handle it.

It's certainly rare when writing applications by hand, but such
limits can be reached with code generators wrapping external resources
such as database query rows, spreadsheet rows, sensor data input, etc.

We've had such a limit before (number of lines in a module) and that
was raised for the same reason.

> Changing the current opcode(s) is a very bad idea, since common cases will
> slow down.

I'm sure there are ways to avoid that, e.g. by using EXTENDED_ARG
for such cases.

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Oct 22 2010)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the Python-ideas mailing list