Conversation
| l2: list[list[tuple[f64, str, tuple[i32, f64]]]] = [] | ||
| i: i32 | ||
|
|
||
| l1.reserve(100) |
There was a problem hiding this comment.
| l1.reserve(100) | |
| reserve(l1, 100) |
| l1.append(i) | ||
| assert len(l1) == i + 1 | ||
|
|
||
| l1.reserve(150) |
There was a problem hiding this comment.
| l1.reserve(150) | |
| reserve(l1, 150) |
| l1.pop(0) | ||
| assert len(l1) == 49 - i | ||
|
|
||
| l2.reserve(100) |
There was a problem hiding this comment.
| l2.reserve(100) | |
| reserve(l2, 100) |
| l2.append([(f64(i * i), str(i), (i, f64(i + 1))), (f64(i), str(i), (i, f64(i)))]) | ||
| assert len(l2) == i + 1 | ||
|
|
||
| l2.reserve(150) |
There was a problem hiding this comment.
| l2.reserve(150) | |
| reserve(l2, 150) |
| @@ -0,0 +1,30 @@ | |||
| from lpython import i32, f64 | |||
There was a problem hiding this comment.
| from lpython import i32, f64 | |
| from lpython import i32, f64, reserve |
| return nullptr; | ||
| } | ||
|
|
||
| static inline ASR::asr_t* create_ListReserve(Allocator& al, const Location& loc, |
There was a problem hiding this comment.
| static inline ASR::asr_t* create_ListReserve(Allocator& al, const Location& loc, | |
| static inline ASR::asr_t* create_Reserve(Allocator& al, const Location& loc, |
| x.base.base.loc, diagnostics); | ||
| } | ||
|
|
||
| static inline ASR::expr_t *eval_list_reserve(Allocator &/*al*/, |
There was a problem hiding this comment.
| static inline ASR::expr_t *eval_list_reserve(Allocator &/*al*/, | |
| static inline ASR::expr_t *eval_reserve(Allocator &/*al*/, |
| {nullptr, &DictValues::verify_args}}, | ||
| {static_cast<int64_t>(ASRUtils::IntrinsicFunctions::ListPop), | ||
| {nullptr, &ListPop::verify_args}}, | ||
| {static_cast<int64_t>(ASRUtils::IntrinsicFunctions::ListReserve), |
There was a problem hiding this comment.
| {static_cast<int64_t>(ASRUtils::IntrinsicFunctions::ListReserve), | |
| {static_cast<int64_t>(ASRUtils::IntrinsicFunctions::Reserve), |
| "list.reverse"}, | ||
| {static_cast<int64_t>(ASRUtils::IntrinsicFunctions::ListPop), | ||
| "list.pop"}, | ||
| {static_cast<int64_t>(ASRUtils::IntrinsicFunctions::ListReserve), |
There was a problem hiding this comment.
| {static_cast<int64_t>(ASRUtils::IntrinsicFunctions::ListReserve), | |
| {static_cast<int64_t>(ASRUtils::IntrinsicFunctions::Reserve), |
| {"list.index", {&ListIndex::create_ListIndex, &ListIndex::eval_list_index}}, | ||
| {"list.reverse", {&ListReverse::create_ListReverse, &ListReverse::eval_list_reverse}}, | ||
| {"list.pop", {&ListPop::create_ListPop, &ListPop::eval_list_pop}}, | ||
| {"list.reserve", {&ListReserve::create_ListReserve, &ListReserve::eval_list_reserve}}, |
There was a problem hiding this comment.
| {"list.reserve", {&ListReserve::create_ListReserve, &ListReserve::eval_list_reserve}}, | |
| {"list.reserve", {&ListReserve::create_Reserve, &ListReserve::eval_reserve}}, |
|
Beautiful. Yes, as Gagandeep said, you just do: Let's get this in and benchmark again. |
|
The latest commit makes these changes. But the test gives this error @czgdp1807 Could you please point where exactly is this to be registered in |
|
@czgdp1807 if you could please help, that would be great. Let's get this finished. |
|
I will meet @kabra1110 today after our meeting ends. We will complete it then. |
|
Thanks @czgdp1807 ! How do the updated benchmarks look like? |
Fixes #2232.
Similar to C++, I have kept this as a function intrinsic to list class.
The test does not work with CPython, as this function is not present there. I'm not entirely sure on how to add a no-op function for this to work.