← 输入框|github.com|刷新
Skip to content

Implement list reserve #2233

Closed
Closed

Description

@certik

Here is how to use it:

from lpython import reserve
def dijkstra_shortest_path(n: i32, source: i32) -> i32:
    i: i32; j: i32; v: i32; u: i32; mindist: i32; alt: i32; dummy: i32; uidx: i32
    dist_sum: i32;
    graph: list[i32] = []
    dist: list[i32] = []
    reserve(graph, n*n)

In CPython emulation this will be an empty function (no-op), in LPython we reserve the memory for this list, similar to reserve in C++, for performance.

Activity

  1. certik commented on Jul 30, 2023

    @certik
    ContributorAuthor

    I think we can use the same function reserve for dicts and sets too, later on.

  2. czgdp1807 commented on Jul 30, 2023

    @czgdp1807
    Collaborator

    Closing this in favour of #2232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions