Closed kmr-srbh closed 2 months ago
@kmr-srbh whenever something works with lpython
, we also need it to work with cpython
and produce a similar output. Can you post the output for the example in the PR description for cpython
? Can you update your other PRs to show output for cpython
? Thanks!
Can you update your other PRs to show output for
cpython
?
I am posting the output. :+1:
% cat examples/expr2.py
print({1: "a"}.values())
% python examples/expr2.py
dict_values(['a'])
% lpython examples/expr2.py
['a']
% cat examples/expr2.py
print({1: "a"}.values()[0])
% python examples/expr2.py
Traceback (most recent call last):
File "/Users/ubaid/Desktop/OpenSource/lpython/examples/expr2.py", line 1, in <module>
print({1: "a"}.values()[0])
TypeError: 'dict_values' object is not subscriptable
% lpython examples/expr2.py
a
It seems technically a list
and a dict_values
are not the same.
Please mark as "Ready for review" when ready.
@certik do you have views on https://github.com/lcompilers/lpython/pull/2661#issuecomment-2078563958? This PR returns dict.values()
as list
. Similarly other PR https://github.com/lcompilers/lpython/pull/2660 returns dict.keys()
as list
. In cpython dict.keys()
and dict.values()
return as object dict_values
and object dict_keys
.
@Shaikh-Ubaid I return a list for dict.keys
and dict.values
following https://github.com/lcompilers/lpython/issues/1881#issuecomment-1605977472
I return a list for dict.keys and dict.values following https://github.com/lcompilers/lpython/issues/1881#issuecomment-1605977472
Thanks for sharing. It makes sense.
After https://github.com/lcompilers/lpython/pull/2660 gets merged, there can be conflicts in this PR. Please resolve them after https://github.com/lcompilers/lpython/pull/2660 is merged. I will give it a final review then.
@Shaikh-Ubaid the conflicts have been resolved.
Working
CPython
LPython