Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compile-time support for list.pop #2659

Merged
merged 12 commits into from
May 1, 2024

Conversation

kmr-srbh
Copy link
Contributor

Working

from lpython import i32

print([1, 2, 3, 4, 5].pop())
print([1, 2, 3, 4, 5].pop(3))

index: i32 = 1
print([1, 2, 3, 4, 5].pop(index))

element_1: i32 = [1, 2, 3, 4, 5].pop()
print(element_1)

element_2: i32 = [1, 2, 3, 4, 5].pop(2)
print(element_2)

print([(1, 2), (3, 4), (5, 6)].pop(1 - 0))
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py
5
4
2
5
3
(3, 4)

Copy link
Collaborator

@Shaikh-Ubaid Shaikh-Ubaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks in a good direction. I posted some comments to improve it further. Thanks for this! Great work!

src/lpython/semantics/python_ast_to_asr.cpp Outdated Show resolved Hide resolved
src/libasr/pass/intrinsic_functions.h Outdated Show resolved Hide resolved
src/libasr/pass/intrinsic_functions.h Outdated Show resolved Hide resolved
src/lpython/semantics/python_attribute_eval.h Outdated Show resolved Hide resolved
tests/reference/asr-func_04-eef2656.stdout Outdated Show resolved Hide resolved
src/lpython/semantics/python_ast_to_asr.cpp Outdated Show resolved Hide resolved
@Shaikh-Ubaid Shaikh-Ubaid marked this pull request as draft April 25, 2024 20:03
@kmr-srbh kmr-srbh force-pushed the list-constant-pop branch from a3ed29e to e515381 Compare April 27, 2024 05:08
@kmr-srbh kmr-srbh marked this pull request as ready for review May 1, 2024 03:44
@kmr-srbh kmr-srbh requested a review from Shaikh-Ubaid May 1, 2024 03:44
Copy link
Collaborator

@Shaikh-Ubaid Shaikh-Ubaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Thanks for this!

@Shaikh-Ubaid Shaikh-Ubaid enabled auto-merge (squash) May 1, 2024 10:37
@Shaikh-Ubaid Shaikh-Ubaid merged commit 8451ad2 into lcompilers:main May 1, 2024
14 checks passed
@kmr-srbh kmr-srbh deleted the list-constant-pop branch May 2, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants