Skip to content

Compute dictionary values ​​in parallel #127459

@vivodi

Description

@vivodi

Feature or enhancement

Proposal:

The following code takes 4 seconds to run. If the values ​​in the dictionary can be calculated in parallel, it only takes 2 seconds.

import asyncio
import time

async def main():
    start = time.time()
    dic = {
        'a': await asyncio.sleep(2),
        'b': await asyncio.sleep(2)
    }
    end = time.time()
    print(f'elapsed time: {end - start} seconds')

asyncio.run(main())

Current output:

elapsed time: 4 seconds

Expected output:

elapsed time: 2 seconds

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions