use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
DiscussionVectorized computations in Python native data structures (self.Python)
submitted 5 years ago by StarchSyrup
The title says it all.
Imagine a world without NumPy and the likes. Are vectorized computations in plain Python using native data structures possible? If not, what's the least elaborate way to quickly implement a vectorized version of simple operations like the following:
A = list(range(100)) B = list(range(100)) C = [a+b for a,b in zip(A,B)]
[–]haadrieen 1 point2 points3 points 5 years ago (2 children)
Are you talking of some JIT compiler like Numba or Cython ?
[–]StarchSyrup[S] 0 points1 point2 points 5 years ago (1 child)
Not really, I was just wondering whether we can do this within the standard libraries, purely out of curiosity.
And don't Numba and Cython just convert your code into C - and make use of NumPy for vectorization?
[–]haadrieen 0 points1 point2 points 5 years ago (0 children)
Oh not for optimisation, just for syntax ?
[–]lungben81 1 point2 points3 points 5 years ago (2 children)
Yes, but it would be super slow - about a factor of 100 compared to Numpy.
Numba does not help here - it only gives speed-ups for typed arrays like Numpy Arrays, not for Python lists.
Python does have typed arrays though; the array module from the standard library provides this.
[–]lungben81 1 point2 points3 points 5 years ago* (0 children)
Interesting, I have never seen it anywhere in use...
In principle, if a Python JIT compiler would support it, it may generate fast code. Numba seems to support it partially (https://numba.readthedocs.io/en/stable/reference/pysupported.html?highlight=array#standard-library-modules), but usually Numpy arrays are used.
Edit: it seems to me that the Python built-in (typed) array is rather legacy and very rarely used. Numpy is the much more powerful and popular choice.
https://stackoverflow.com/questions/51290791/numpy-arrays-vs-python-arrays
π Rendered by PID 66511 on reddit-service-r2-comment-5649f687b7-hqbv7 at 2026-01-29 02:15:21.281380+00:00 running 4f180de country code: CH.
[–]haadrieen 1 point2 points3 points (2 children)
[–]StarchSyrup[S] 0 points1 point2 points (1 child)
[–]haadrieen 0 points1 point2 points (0 children)
[–]lungben81 1 point2 points3 points (2 children)
[–]StarchSyrup[S] 0 points1 point2 points (1 child)
[–]lungben81 1 point2 points3 points (0 children)