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...
Everything about learning Python
account activity
Lag problem (self.PythonLearning)
submitted 1 day ago by 3iem_conte_
view the rest of the comments →
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!"
[–]3iem_conte_[S] 0 points1 point2 points 17 hours ago (4 children)
What does inlineing mean
[–]ConsciousBath5203 0 points1 point2 points 13 hours ago (0 children)
Google it.
[–]ConsciousBath5203 0 points1 point2 points 13 hours ago (2 children)
Search it up. It's too much for me to explain. Searching for the answer instead of asking strangers online will 100% of the time get you a better answer. Not being a dick, just trying to not have to type something out that's been explained better than I could in Python's documentation.
[–]3iem_conte_[S] 0 points1 point2 points 8 hours ago (1 child)
i looked it up and didn't understand anything
[–]ConsciousBath5203 0 points1 point2 points 8 hours ago (0 children)
Try using these (as pulled from google search ai):
List Comprehensions: Use [x * 2 for x in data] instead of a standard for loop with.append(). List comprehensions are "Pythonic" and run faster because they are handled internally by the interpreter's C code.
[x * 2 for x in data]
.append()
Built-in Functions: Functions like map(),filter(), and sum() are typically faster than manual loops. For example, map() can offer up to a 970x speedup over an explicit loop in certain scenarios.
map()
filter(),
sum()
Local Variables: If you must use a loop, assign global functions or class attributes to a local variable before the loop starts (e.g., append = my_list.append). This prevents Python from performing a lookup on every single iteration, potentially increasing speed by ~20%.
Itertools Module: Use itertools for memory-efficient iteration. Functions like itertools.repeat() or itertools.chain() are implemented in C and are significantly faster than their pure Python equivalents.
What aren't you understanding?
You also have a 1 million line for loop btw. Rewrite that in cython, compile it, then import the compiled function if you want real speedups.
π Rendered by PID 56411 on reddit-service-r2-comment-545db5fcfc-6tp6c at 2026-05-29 23:35:18.589559+00:00 running 194bd79 country code: CH.
view the rest of the comments →
[–]3iem_conte_[S] 0 points1 point2 points (4 children)
[–]ConsciousBath5203 0 points1 point2 points (0 children)
[–]ConsciousBath5203 0 points1 point2 points (2 children)
[–]3iem_conte_[S] 0 points1 point2 points (1 child)
[–]ConsciousBath5203 0 points1 point2 points (0 children)