Collin Winter wrote:
> On 8/8/06, Josiah Carlson <[EMAIL PROTECTED]> wrote:
>> I personally don't see much of a use for set literals, considering that
>> there is a non-ambiguous spelling of it currently; set(...), whose only
>> cost above and beyond that of a set literal is a global name lookup.

> I thought one of the main arguments in favor of set literals is that a
> literal form would allow the compiler to perform optimisations that
> the set(...) spelling doesn't allow.

A different way to enable that would be to include a set of non-keyword names 
(a subset of the default builtin namespace) in the language definition that 
the compiler is explicitly permitted to treat as constants if they are not 
otherwise defined in the current lexical scope.

Then constant-folding could turn "len('abcde')" into 5, and "str(3+2)" into 
'5' and "set((1, 2, 3))" into the corresponding set object.

The only thing that would break is hacks like poking an alternate 
implementation of str or set or len into the global namespace from somewhere 
outside the module.

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to