Question on difference between LambdaType and FunctionType

Chris Angelico rosuav at gmail.com
Sun Nov 25 15:55:08 EST 2018


On Mon, Nov 26, 2018 at 7:52 AM Iwo Herka <iwoherka at gmail.com> wrote:
>
> > Why are lambda functions not instrumented?
>
> Because, if I didn't forget about anything, assignment
> in lambdas is invalid. That is,
>
>      lambda self. self.x = 1
>
> or
>
>      lambda self: (self.x = 1)
>
> will throw SyntaxError. Therefore, I don't have to worry
> that someone will attempt to mutate the object from lambda.
>

Ahh, so this is an optimization. The question is: Do you need to worry
about the lambda function calling another function? See my example
above.

ChrisA



More information about the Python-list mailing list