[Python-Dev] constant/enum type in stdlib

Michael Foord fuzzyman at voidspace.org.uk
Mon Nov 29 01:57:27 CET 2010


On 29/11/2010 00:48, Nick Coghlan wrote:
> On Mon, Nov 29, 2010 at 2:28 AM, Michael Foord
> <fuzzyman at voidspace.org.uk>  wrote:
>> For wrapping mutable types I'm tempted to say YAGNI. For the standard
>> library wrapping integers meets almost all our use-cases except for one
>> float. (At work we have a decimal constant as it happens.) Perhaps we could
>> require immutable types for groups but allow arbitrary values for individual
>> named values?
> Whereas my opinion is that "immutable vs mutable" is such a blurry
> distinction that we shouldn't try to make it at the lowest level.
> Would it be possible to name frozenset instances? Tuples? How about
> objects that are conceptually immutable, but don't close all the
> loopholes allowing you to mutate them? (e.g. Decimal, Fraction)
>
> Better to design a named value API that doesn't care about mutability,
> and then leave questions of reverse mappings from values back to names
> to the grouping API level. At that level, it would be trivial (and
> natural) to limit names to referencing Hashable values so that a
> reverse lookup table would be easy to implement. For standard library
> purposes, we could even reasonably provide an int-only grouping API,
> since the main use case is almost certainly to be in managing
> translation of OS-level integer constants to named values.

Sounds reasonable to me.

Michael

> Cheers,
> Nick.
>


-- 

http://www.voidspace.org.uk/

READ CAREFULLY. By accepting and reading this email you agree,
on behalf of your employer, to release me from all obligations
and waivers arising from any and all NON-NEGOTIATED agreements,
licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap,
confidentiality, non-disclosure, non-compete and acceptable use
policies (”BOGUS AGREEMENTS”) that I have entered into with your
employer, its partners, licensors, agents and assigns, in
perpetuity, without prejudice to my ongoing rights and privileges.
You further represent that you have the authority to release me
from any BOGUS AGREEMENTS on behalf of your employer.



More information about the Python-Dev mailing list