Author lschoe
Recipients asvetlov, lschoe, vstinner, yselivanov
Date 2020-12-03.15:34:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The async REPL introduced in Python 3.8 is very nice for quick tests and experiments, supporting top-level "await" (see I'm using it often when developing code that heavily relies on Python's asyncio module.

A drawback of the basic interface when launching it with "python -m asyncio" is that one usually still needs to enter a couple of statements to load the package you're working on, etc. To overcome this I've added a to the mpyc package such that entering "python -m mpyc" will launch the async REPL like this: 

	asyncio REPL 3.10.0a2 (tags/v3.10.0a2:114ee5d, Nov  3 2020, 00:37:42) [MSC v.1927 64 bit (AMD64)] on win32
	Use "await" directly instead of "".
	Type "help", "copyright", "credits" or "license" for more information.
	>>> import asyncio
	>>> from mpyc.runtime import mpc
	>>> secint = mpc.SecInt()
	>>> secfxp = mpc.SecFxp()
	>>> secfld256 = mpc.SecFld(256)

This enables the async REPL but also a "preamble" with some additional code is executed.

To program, however, I basically had to copy and make a few changes throughout the code. It works alright, but to take advantage of future improvements to it would be very convenient if becomes reusable. 

With the added feature for specifying a "preamble", programming something like requires just a few lines of code:

    import asyncio.__main__
    if __name__ == '__main__':
        preamble = ('from mpyc.runtime import mpc',
                    'secint = mpc.SecInt()',
                    'secfxp = mpc.SecFxp()',
                    'secfld256 = mpc.SecFld(256)')

The attachment contains the current version of, which to a large extent duplicates code from A couple of, I think, minor changes are applied to make the code reusable, and to add the preamble feature.

Would be nice if is updated in this manner in Python 3.10 such that package developers can tailor it to their needs?
Date User Action Args
2020-12-03 15:34:45lschoesetrecipients: + lschoe, vstinner, asvetlov, yselivanov
2020-12-03 15:34:45lschoesetmessageid: <>
2020-12-03 15:34:45lschoelinkissue42557 messages
2020-12-03 15:34:45lschoecreate