Any ideas for a new language inspired to Python?

Chris Angelico rosuav at gmail.com
Sun Aug 9 19:02:57 EDT 2020


On Mon, Aug 10, 2020 at 2:46 AM Marco Sulla
<Marco.Sulla.Python at gmail.com> wrote:
> This is another big problem: everything is an object?
> It seems that in practice, using integers and floats as objects leads
> to great slowdowns. And personally I never saw people that created
> superclasses of int or float. Anyway, if they feel the urgence, they
> can use `numbers` ABCs. It seems to me that the Java separation
> between primitive types vs objects is quite practical.

That isn't a problem. It is, in fact, extremely practical. EVERY
Python object has a repr, EVERY Python object has a type, etc, etc,
etc. You can ask questions like "is this object an instance of
(float,int)" and get back a useful answer.

If you *really* want to get away from ints-as-objects, what I would
recommend is emulating it. Some languages pretend that everything's an
object, but for small integers (say, those less than 2**60), it
doesn't store the object itself, it just stores the integer (with the
low bit set, for example). It requires special-casing integers
*everywhere* in the language executor (interpreter/compiler), and in
return, you get to save about 20 bytes per integer compared to the way
CPython does it. Is that worth it?

ChrisA


More information about the Python-list mailing list