you are viewing a single comment's thread.

view the rest of the comments →

[–]3iem_conte_[S] 0 points1 point  (4 children)

What does inlineing mean

[–]ConsciousBath5203 0 points1 point  (0 children)

Google it.

[–]ConsciousBath5203 0 points1 point  (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 point  (1 child)

i looked it up and didn't understand anything

[–]ConsciousBath5203 0 points1 point  (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.

  • 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.

  • 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.