[Python-ideas] 'Injecting' objects as function-local constants

Jan Kaliszewski zuo at chopin.edu.pl
Mon Jun 20 13:34:11 CEST 2011

Nick Coghlan dixit (2011-06-17, 17:02):

> I already have too much on my to-do list to champion a PEP for this,
> but I'd be happy to help someone else with the mechanics of writing
> one and getting it published on python.org (hint, hint Jan!).

Nick Coghlan dixit (2011-06-19, 16:56):

> What is needed now is one or more volunteers that are willing and able to:
> 1. Write a PEP that:
>   - distils the core discussion in this thread down into a specific
> proposal that can be brought up on python-dev
>   - explains *why* the default argument hack is undesirable in general
> (unintuitive, hard to look up, harmful to introspection, invites
> errors when calling affected functions)
>   - clearly articulates the uses of the default argument hack that the
> proposal aims to eliminate (early binding, shared locals, performance)
>   - include real world example of such uses from the standard library
> (and potentially other code bases)
>   - optionally, also describe the potential "function factories" that
> could be developed based on the semantics I proposed (see Eric Snow's
> post for a sketch of how such factories might work once given a
> template function to work with)
> 2. Create a reference implementation targeting Python 3.3
> (with step 1 being significantly more important at this stage - while
> the implementation can't be called *easy*, it should be a reasonably
> straightforward combination of the existing code that handles nonlocal
> statements and that which handles the calculation and storage of
> default arguments).
> I'm not going to do it myself (I already have a couple of open PEPs
> that I need to make the time to follow up on), but I'm more than happy
> to provide pointers and advice to someone else that steps up to do so.

I could do it with pleasure, at least step #1 -- i.e. writing a PEP
(step #2 seems to be quite non-trivial :), though for sure would be very

*But* -- only provided that it would be known and accepted that *I could
not act urgently nor quickly* at all (I got a new job recently and even
don't know yet how much spare time per week would I be able to save up
during incoming months).

Would that be OK?


More information about the Python-ideas mailing list