[Email-SIG] invertability and idempotence
barry at python.org
Thu Oct 22 13:36:12 CEST 2009
On Oct 21, 2009, at 6:58 PM, R. David Murray wrote:
> But it turns out that idempotence does have a meaning in the context
> of the email module, so I think I need to remove 'depreciated' from
> my glossary entry for it, and explain what it means in the context
> of the email module.
I think you're onto something here.
> For background, see issue 7119.
> Here's what I propose: _invertability_ applies to the data path
> into the parser and out of the generator. That is:
> generate(parse(msg)) == msg
> should be true whenever possible.
Agreed, where 'msg' in this context means the message text or bytes.
> On the other hand, when _constructing_ a message, sometimes not all
> is filled in (in the example above, it is the MIME boundary marker).
> In that case, it is important (I think, please discuss :) that
> the message maintain _idempotency_: once you have generated the
> then if you have not further mutated the message, generating the
> again should produce the _same_ output. That is:
> generate(msg) == generate(msg)
> even though the state of msg may change after the _first_ generate
"Idempotent" means: "multiple applications of the operation do not
change the result". So here where the operation is to take a message
object and generate a stream of text or bytes, this should absolutely
return the same stream if the object is not mutated between calls. I
think it's fair though that if the model is manipulated in any way, we
make no guarantees of idempotency, though we should strive for minimal
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 832 bytes
Desc: This is a digitally signed message part
More information about the Email-SIG