This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients Demur Rumed, benjamin.peterson, brett.cannon, georg.brandl, ncoghlan, serhiy.storchaka, vstinner, yselivanov
Date 2016-05-30.14:02:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464616961.71.0.503051347327.issue27140@psf.upfronthosting.co.za>
In-reply-to
Content
> Perhaps BUILD_CONST_KEY_MAP?

LGTM.

> Ideally the opcode could ellide the LOAD_CONST for the tuple. ie have LOAD_CONST 2 (1, 2, 3), BUILD_CONST_KEY_MAP 3 be BUILD_CONST_KEY_MAP 2 (1, 2, 3). However that'd require stack_effect to somehow lookup the const tuple

I like this idea. But PyCompile_OpcodeStackEffect() doesn't have an access to the consts dict.

> Relying on the peepholer seems unideal; it does more work than generating the tuple the first time & doing it eagerly will produce a more compact stack depth & co_consts

I thought that this would be not easy. But thanks to your encouraging I have tried to do this and the result is pretty simple.

In updated patch the opcode name was changed to BUILD_CONST_KEY_MAP, and the compiler no longer depends on the peephole optimizer for generating constant keys tuple. Thank you Demur.
History
Date User Action Args
2016-05-30 14:02:43serhiy.storchakasetrecipients: + serhiy.storchaka, brett.cannon, georg.brandl, ncoghlan, vstinner, benjamin.peterson, yselivanov, Demur Rumed
2016-05-30 14:02:41serhiy.storchakasetmessageid: <1464616961.71.0.503051347327.issue27140@psf.upfronthosting.co.za>
2016-05-30 14:02:41serhiy.storchakalinkissue27140 messages
2016-05-30 14:02:41serhiy.storchakacreate