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

dict.items() set/list/tuple value segmentation fault & reverse items loop #322

Open
ghost opened this issue Jun 25, 2023 · 2 comments
Open

Comments

@ghost
Copy link

ghost commented Jun 25, 2023

I'm not entirely sure on Python 3 version differences so I'm not entirely sure if these are considered issues for PikaPython. But I'm creating this issue just in case if these are considered issues.

I tested this code and it results in segmentation fault. It does not matter if it's using (), {} or [], all of them seg fault.

dict = {
    'a': {1, 2, 3},
    'b': {4, 5, 6},
    'c': {7, 8, 9},
}

for k, (a, b, c) in dict.items():
    print(k, ':', a, b, c)

Another thing that was unexpected to me was this going through the dictionary in reverse.

dict = {
    'a': 1,
    'b': 4,
    'c': 7,
}

for k, a in dict.items():
    print(k, ':', a)

Output:

c : 7
b : 4
a : 1
@pikasTech
Copy link
Owner

pikasTech commented Jun 25, 2023

Thank you for bringing these issues to our attention.

I regret to inform you that the current version of PikaPython does not support some of the features you've tried to use:

  • The advanced tuple unpacking syntax is currently not implemented. This might lead to unexpected behavior if employed in your code.for x, (x,x,x) in ...

  • Sets, as indicated by syntax, are not supported at this time, meaning that any code utilizing sets may not execute as anticipated.{1, 2, 3}

  • Additionally, the order-preserving characteristic of dictionaries, a feature introduced in Python 3.7, is not yet supported in our platform. Consequently, when you iterate over a dictionary, the items may not be returned in the order they were inserted.

We recognize the importance of these features and our development team is actively working to incorporate them into future versions of PikaPython. For the time being, we suggest that you maintain this issue open. Once these features are integrated, I will personally update you in this thread.

In the interim, I recommend simplifying your code. For instance, when iterating over dictionary items, you could use a single variable like so: . Moreover, I suggest avoiding the use of sets and dependence on dictionary order to prevent any unpredictable behavior.for x, y in ...: a,b,c=y

Thank you for your understanding and patience. We truly value your feedback as it helps us improve our platform and better serve our users. Please don't hesitate to reach out if you have any further concerns or queries.

@pikasTech
Copy link
Owner

fixed the reverse of dictionary iter.
image

ca2820e

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

No branches or pull requests

1 participant