faster-cpython / ideas

1.67k stars 49 forks source link

Remove special syntax for super(X) = A + B in favor of macro(X) = A + JOIN + B #508

Closed gvanrossum closed 1 year ago

gvanrossum commented 1 year ago

This can now be expressed as a macro using A + JOIN + B.

See also python/cpython#100124 and #507.

markshannon commented 1 year ago

Implementing superinstructions as A + JOIN + B probably make sense, but I'd rather have the DSL be explicit about superinstructions.

Parsing superinstructions should be simple. Do we gain much by removing that code?

gvanrossum commented 1 year ago

Implementing superinstructions as A + JOIN + B probably make sense, but I'd rather have the DSL be explicit about superinstructions.

I guess we could rename JOIN to SUPER, would that be explicit enough?

Parsing superinstructions should be simple. Do we gain much by removing that code?

You can see for yourself in https://github.com/python/cpython/pull/100124/commits/eadca5182a47d30324e6a8da6471a061165c665d. That commit removes about 80 lines net, or about 6% of the generator and parser. About 60 lines are removed from the generator, about 20 from the parser proper.

See also https://github.com/faster-cpython/ideas/issues/495 which asks a related question.

gvanrossum commented 1 year ago

FWIW after reading Brandt's review of the cpython PR I'm rather hesitant about this.

gvanrossum commented 1 year ago

Off-line we decided not to do this.