-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
array comprehension #4716
Comments
btw. pythonic list comprehensions are much faster than using map in python, so maybe there is some nice way to implement it as fast |
First of all thank you for your report and sorry for the delay. We released Godot 3.0 in January 2018 after 18 months of work, fixing many old issues either directly, or by obsoleting/replacing the features they were referring to. We still have hundreds of issues whose relevance/reproducibility needs to be checked against the current stable version, and that's where you can help us. For bug reports, please also make sure that the issue contains detailed steps to reproduce the bug and, if possible, a zipped project that can be used to reproduce it right away. This greatly speeds up debugging and bugfixing tasks for our contributors. Our Bugsquad will review this issue more in-depth in 15 days, and potentially close it if its relevance could not be confirmed. Thanks in advance. Note: This message is being copy-pasted to many "stale" issues (90+ days without activity). It might happen that it is not meaningful for this specific issue or appears oblivious of the issue's context, if so please comment to notify the Bugsquad about it. |
This is still valid in master: list/array comprehensions have not been added yet. |
As we rejected a PR implementing this feature (#15222), I think we'll close this feature proposal as not wanted for the reasons described in the PR:
|
:/ Also I disagree thats list comprehensions are unreadable; we even had them as part of basic curriculum on Python course at University (afair it was first semester). |
This is a completely ridiculous assertion. List comprehensions are declarative and describe exactly what the final data will be. Loop filling an array or list has never been as readable as a comprehension or a map function. Having to separately parse array creation, iteration bounds, conditions, and finally what is being entered into the array location (and how) is a relic of a process, a byproduct of C's dominance due to hardware limitations 40 years ago. When manipulating data, few programmers are so constrained that they think they can do better than the compiler by describing how to create an array rather than what should go in it. You're never going to tell me that
is harder to read than
which is noisy as all get-out. |
Honestly, I think not having list comprehension is more confusing, since it's such an integral part of python. It could also allow for syntax such as
Obviously, that's not constant. This would allow us access to these constant arrays in nested classes, which is today impossible unless you pass it as argument (#4472). I understand that constant arrays is a different discussion (#32063), but I'd just like to mention that there are uses in which array comprehension syntax makes sense. Besides, of course, being pythonic (which I think is argument enough). |
would be nice to be able to create arrays using pythonish comprehension like
array = [[0 for y in range(10)] for x in range(10)]
or even with conditionals like
array = [i for i in range(10) if i % 2]
it also enables to simulate 'map' function like
result_array = [item.count - 1 for item in other_array if item.type == 'bullet']
The text was updated successfully, but these errors were encountered: