[Python-3000] Brainstorming: literal construction hooks

Guido van Rossum guido at python.org
Sat Apr 22 16:38:12 CEST 2006


On 4/22/06, Nick Coghlan <ncoghlan at gmail.com> wrote:
> No matter what, permitting these kinds of hooks is going to require
> alterations to the process of compiling the AST to the bytecode - and
> subclassing is an excellent way of allowing some aspects of an implementation
> to be overridden while leaving other aspects alone.

Oops, I have to concur.

I was thinking that it could all be done later, at run-time. That
makes sense for things like [...] and {...} but doesn't really work
for floating point or even string literals -- you can't afford the
overhead of calling a default hook for each literal at run-time, and
passing the default value to the hook doesn't work in the case of
floats or strings.

Unfortunately a compile-time hook is much more painful to add to the
language because it means adding new syntax just to specify the hooks.
:-(

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list