Subclassing built-in classes

hanumizzle hanumizzle at gmail.com
Sat Oct 7 03:35:26 EDT 2006


On 10/7/06, Gabriel Genellina <gagsl-py at yahoo.com.ar> wrote:
> At Friday 6/10/2006 06:58, Maric Michaud wrote:
>
> >As the first post said "...couldn't python (in theory)...", I was discussing
> >if it would be possible for python (in some future version) to manage the
> >literals so that they use the constructors in the __builtin__ module, I
> >didn't say it works actually (I'm aware it's not the case).
>
> The idea looks crazy for me... You suggest that code like this:
>
>          x = 12 + 6.0 - len('ABCD'
>
> would be evaluated at run time as it were:
>
>          x = int('12') + float('6.0') - len(str('ABCD'))
>
> Certainly would slow down the whole execution time *a*lot*, with no
> benefit for almost nobody, if *every* reference to *any* literal in
> the code calls a python function at run time.
> And unless you return *exactly* the same object as now, almost all
> code would break!
> Do you have any useful usage for this?

Sometimes I've had weird ideas that I thought might be useful, but
they turned out to be doo doo. On other occasions, the SWAG paid off
(e.g., vesa driver runs faster than accelerated via driver for
compositing in Xorg) It's all a matter of proposing and disposing, and
mistakes happen.

Somehow, I missed Python's round() function and came up with
convoluted solution involving decimal. Gee duh, Theerasak

-- Theerasak



More information about the Python-list mailing list