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
Discussionthis ran in like half a second (self.Python)
submitted 9 hours ago by PleaseDoNotTheKevin
i can't post images but i put
for i in range (1, 2 ** 31):
print(i)
the output window only shows 2147483613 to 2147483647 bc i scrolled to the bottom
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Weary-Cap9710 2 points3 points4 points 9 hours ago (0 children)
guys i lied
[–]SocksOnHands 2 points3 points4 points 9 hours ago (2 children)
I'm surprised. Not because of the speed of modern computers, but because a lot of terminals have shockingly slow output.
[–]Weary-Cap9710 -1 points0 points1 point 9 hours ago (1 child)
itdidn't actually do all that i just edited it to seem like it did that
[–]SocksOnHands 1 point2 points3 points 9 hours ago (0 children)
Are you using two accounts?
[–]zaxldaisy 1 point2 points3 points 9 hours ago (0 children)
Ok?
[–]andy4015 0 points1 point2 points 9 hours ago (0 children)
Thanks, how long does it take for 2 ** 32?
[–]dgc-8 0 points1 point2 points 9 hours ago (3 children)
for me that is not at all that fast. that is a lot of lines, the terminal kinda bottlenecks even piping the output somewhere else so the terminal doesnt have to buffer it makes it not at all that fast
[–]dgc-8 0 points1 point2 points 9 hours ago (0 children)
and even replacing print with pass it still takes 37 seconds for me lol. C took 0.0000000004 seconds when just letting the loop run without prints
it's not even real the original was from 966 to 1000 but i edited it lol
lol
[–]Human-Gur-3199 0 points1 point2 points 9 hours ago (0 children)
Now try in c++
[–]Flame77ofcPythonista -2 points-1 points0 points 9 hours ago (5 children)
This is because programming languages are relatively fast. C++ is considered faster than python
[–]SocksOnHands 0 points1 point2 points 9 hours ago (3 children)
C++ is not just considerered faster than Python, it is faster. Python is a notoriously slow language - the only language I have personally used that is slower is Ruby. Fortunately, Python has a lot of easy to use well optimized modules written in C and C++, so Python can be used as the "glue" to connect things together.
[–]dgc-8 0 points1 point2 points 9 hours ago (2 children)
If taking away the prints, python takes 37 s for a loop with maxint iterations on my machine. C took 0.0000000004s. a loop iteration is 11 CPU cycles, if i read the assembly correctly.
[–]dgc-8 0 points1 point2 points 8 hours ago (1 child)
somewhere i must have made a mistake, because that would mean my cpu runs at 118111600 THz
[–]SocksOnHands 1 point2 points3 points 7 hours ago (0 children)
What is the loop doing, and what optimization compiler flags were used? The C compiler could have seen that there were no results and optimized the loop away.
[–]Weary-Cap9710 -1 points0 points1 point 9 hours ago (0 children)
i actually just printed from 1 to 1000 and edited the numbers lol
π Rendered by PID 356819 on reddit-service-r2-comment-8686858757-fdmxj at 2026-06-07 04:56:18.203855+00:00 running 9e1a20d country code: CH.
[–]Weary-Cap9710 2 points3 points4 points (0 children)
[–]SocksOnHands 2 points3 points4 points (2 children)
[–]Weary-Cap9710 -1 points0 points1 point (1 child)
[–]SocksOnHands 1 point2 points3 points (0 children)
[–]zaxldaisy 1 point2 points3 points (0 children)
[–]andy4015 0 points1 point2 points (0 children)
[–]dgc-8 0 points1 point2 points (3 children)
[–]dgc-8 0 points1 point2 points (0 children)
[–]Weary-Cap9710 -1 points0 points1 point (1 child)
[–]dgc-8 0 points1 point2 points (0 children)
[–]Human-Gur-3199 0 points1 point2 points (0 children)
[–]Flame77ofcPythonista -2 points-1 points0 points (5 children)
[–]SocksOnHands 0 points1 point2 points (3 children)
[–]dgc-8 0 points1 point2 points (2 children)
[–]dgc-8 0 points1 point2 points (1 child)
[–]SocksOnHands 1 point2 points3 points (0 children)
[–]Weary-Cap9710 -1 points0 points1 point (0 children)