[Python-ideas] Suggestion for standardized annotations
Cem Karan
cfkaran2 at gmail.com
Sun Mar 9 02:54:07 CET 2014
On Mar 8, 2014, at 7:05 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Cem Karan wrote:
>> There are a number of reasons I'm suggesting UUIDs instead of simple strings:
>
> I'm not talking about strings, I'm talking about
> objects created and exported by the module defining
> the annotations, and compared by identity.
>
> The Python module namespace then ensures they have
> unique names within any given program. That's all
> you need, because there's no requirement to persist
> them from one program execution to another.
>
> --
> Greg
I see your point, and I think you're right. I can see a lot of really good additional tricks we can play (adding in metadata to the sentinel, etc.). I've spent the time since I saw this message trying to come up with good counterarguments and I honestly can't come up with any good ones. I can only think of two counterarguments, both of which are really weak. First, if you want to mock the module, you don't need the module's sentinel; you just need the UUID, and then you never need to load the module at all. Second, there are cases where you want to warn people that although the signature of a function has remained the same, the semantics have shifted. In this case, a module user might want to key off of the UUID. If the ID changes, then the meaning has shifted. Both of those counterarguments are really weak though, so unless anyone can think of a reason NOT to use sentinels as Greg suggests, I'd like to shift my proposal to using sentinels instead of UUIDs.
Thanks,
Cem Karan
More information about the Python-ideas
mailing list