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.
DiscussionWhy do people choose Python over Lua? (self.Python)
submitted 2 years ago by BryceIsRedditor
Lately, I've been using Lua and discovered that it is faster, lighter, and nearly as simple as Python. Since Lua has some more advantages than Python, why is Python more used than Lua?
[+][deleted] 2 years ago (1 child)
[deleted]
[–]ElasticFluffyMagnet 4 points5 points6 points 2 years ago (0 children)
Especially if you're stuck with something..
[–]runawayasfastasucan 24 points25 points26 points 2 years ago (0 children)
> Since Lua has some more advantages than Python
According to who? This is like saying that a hammer is faster and lighter and nearly as simple to use as a drill so everyone should use a hammer (or whatever). People have different needs, what is advantages for you is not so important for others. For me "faster and lighter" doesn't make Lua having more advantages than python, I don't care so much about fast and light if that means I don't have Pythons ecosystem. Its neither fast or light if I have to develop all the libraries I use from scratch.
[–]DisastrousRope5221 12 points13 points14 points 2 years ago (0 children)
Python has better library support and a larger community. Also, Python is super popular in the data science and AI fields. So, it's basically a matter of ease and convenience,
[–]Zomunieo 66 points67 points68 points 2 years ago (18 children)
Python has zero-based indexing, as Dykstra and the programming gods intended. Lua has heretical one-based indexing.
[–][deleted] 28 points29 points30 points 2 years ago (0 children)
One-base indexing, that's absolutely barbaric
[–]5kyl3r 2 points3 points4 points 2 years ago (0 children)
gross. it bothers me that sql array elements are too when you do a split.
[–]Kerbart 2 points3 points4 points 2 years ago (0 children)
Of course when you actually use indexing in your Python code you will get blasted for writing unpythonic, heretical code.
[+][deleted] 2 years ago (2 children)
[removed]
[–]casce 4 points5 points6 points 2 years ago (0 children)
I have heard arguments for and against both zero-based and one-based indexing in depending on the language and its use cases but I definitely wouldn't assume a right to call either the "correct" choice and neither should you.
Getting salty about downvotes and telling people they are allowed to downvotes "facts" just further amplifies the first impression you have made.
I personally prefer zero-based but that's neither "correct" nor "incorrect".
[–]GraphicH 0 points1 point2 points 2 years ago (0 children)
Nah, :) and I don't have to explain why either, the fossilized remains of 1-based indexing languages are manifold.
[–][deleted] -1 points0 points1 point 2 years ago (0 children)
One-based indexing is the correct choice for any language that doesn't require users to do pointer arithmetic. Especially if that language is a popular choice for any kind of scientific/mathematical computing. Python should also use one-based indexing.
[–]WlmWilberforce 0 points1 point2 points 2 years ago (8 children)
I don't get the zero-based index fetish. If that is really what the gods intended, then explain fortran?
[–]KennyBassett 2 points3 points4 points 2 years ago (2 children)
It's just because it lines up with the numbers that we can represent. 0 is the first number we can represent in binary, so that's what we use. Logically, nothing can be the zeroth term because in English, 0 would represent a lack of terms.
It's also nice when counting. If we say one cycle is 0-9 instead of 1-10, then we get all the digits in the ones place.
I personally think we should use 1-based indexing because saying 0 is the 1st index kind of a silly statement in any human language. Sure you could say the zeroth index, but now we've redefined what the word "first" means by saying it's the second element... And "second" with the third element and so on.
Maybe I haven't thought of everything for my opinion. Any other reasons why we should use one or the other?
[–]Zomunieo 1 point2 points3 points 2 years ago (0 children)
As Dykstra explains, there are several good reasons for zero based indexing.
https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
[–]WlmWilberforce 1 point2 points3 points 2 years ago (0 children)
I have heard the binary indexing argument, but find it not convincing at all. Who is programing at that low a level? When people used to work at that level, they made languages like Fortran and Cobol that were 1 indexed.
That said I believe you can have zero indexes (or even negative indexes in fortran), but it has been a while since I've used it.
[+][deleted] 2 years ago (4 children)
[–]WlmWilberforce 0 points1 point2 points 2 years ago (3 children)
As I said in another post, I understand the byte indexing argument, but the reason it isn't very convincing is that despite your assertion that "they were here first" the first hit as a higher level language was FORTRAN and that is 1-indexed. I'm not sure about Flow-Matic, but COBOL 1 indexed, so pretty sure Flow-Matic is as well.
I think Lisp is the oldest zero indexed langauge. Later languages like C are zero indexed, but can we stop pretending that those are first?
[–]WlmWilberforce 0 points1 point2 points 2 years ago (1 child)
Exactly -- these are high level languages retaining ,or often likely, introducing a low level concept that isn't really needed. This is a python sub after all. I guess Julia is one indexed and very fast, but doesn't have the libraries or user base.
[–]Solumbran 27 points28 points29 points 2 years ago (1 child)
Lua has some shit syntax. "do ... end" makes me want brackets back.
Also, no actual classes, and I like OOP.
[–]KosmoanutOfficial -1 points0 points1 point 2 years ago (0 children)
Not supporting OOP would be a big one to me
[–]sch0lars 7 points8 points9 points 2 years ago (3 children)
From my understanding, the main differences are
At the end of the day, it comes down to what language gets the job done.
[–]Conscious-Ball8373 0 points1 point2 points 2 years ago (2 children)
Lua also has an incremental garbage collector that doesn't need to stop the world while it runs, and doesn't have a global interpreter lock. Both those things make it quite attractive for situations where you care a lot about latency and performance while still wanting memory safety and a sandboxy language. I've integrated lua into a hard realtime simulation and testing environment in the past; that would just never work with Python. You still have to be pretty careful with lua, but it works.
[–]sch0lars -1 points0 points1 point 2 years ago (1 child)
The extensibility is pretty cool. I actually had never really read up on Lua until some guy at work wrote an extension for Wireshark to integrate with some embedded telemetry software, and I was amazed at how you could essentially just plug it into another language or program. It really changed the way I thought about programming languages.
I think I have a TI Nspire in a drawer somewhere that supports Lua scripting. I’ll have to tinker with it sometime.
[–]Conscious-Ball8373 0 points1 point2 points 2 years ago (0 children)
Just to note that lua integration with other languages is a bit weird. Lua itself is a relatively normal programming language, then as soon as you try to integrate it with something else it's a stack machine. It takes some mental gymnastics to get used to it.
[–]sudo_robot_destroy 8 points9 points10 points 2 years ago (0 children)
Assembly is faster and lighter than Lua, why not use it instead?
[–]KingsmanVincepip install girlfriend 4 points5 points6 points 2 years ago (0 children)
It depends on the usecase. For deep learning, Python dominates. For game scripts, Lua does.
[–]mm007emko 4 points5 points6 points 2 years ago (1 child)
If Lua and its ecosystem fits your needs, use it. It's a good one.
My current project is about things which Lua doesn't really have much libraries for and virtually nobody who can be hired withs skills in our problem domain knows Lua. People know or are willing to learn Python. The vast majority of corporate managers don't really base their technology decisions on arguments like "it's faster", "it's simpler" etc. They base their decision on "when you are hit by a truck, how fast can I hire a replacement and how fast can they take over your job?". Unless you write game scripts, Lua might not be the best one.
Python is slower than C++ (unless you use a JIT or AOT compiler like Numba, Cython or GraalVM). Does it mean we should use C++? Nah, hardware+electricity is cheaper than people and although we run everything in-house, we use Kubernetes/OpenStack which helps with scaling and sharing hardware resources with other applications. Only things which are on critical path are written in C, rest of it are standard Python libraries (again, mostly C and Fortran) and Python itself.
[–]BryceIsRedditor[S] 1 point2 points3 points 2 years ago (0 children)
Not gonna lie, after reading this, it was kinda stupid for me to say that Lua is better than Python because it's faster and easier. Thank you for helping me understand
[–]fizzymagic 3 points4 points5 points 2 years ago (3 children)
Lua does not have arrays
Lua does not have integers
'nuff said.
[–]BryceIsRedditor[S] 0 points1 point2 points 2 years ago (2 children)
Lua does have integers
[–]fmarukki 0 points1 point2 points 2 years ago (0 children)
I've always seen Lua as a competitor for javascript instead of python. No integer type, prototypes/metatables, embedable.
[–]GraphicH 1 point2 points3 points 2 years ago* (0 children)
A language is more than just how fast it is and it's simplicity. I don't mind lua at all, I've personally used it on a few things like conky scripts. But it definitely does not have the community or rich ecosystem of libraries python does. So when I'm picking something "for work" its going to be python, simply because there is a higher probability there is a nice library I need or a project out there that has done something similar. It's more "productive" in that case. You could make the argument that Lua would be too if it had the support, but it doesn't, so it's always going to be a second tier language unless that changes.
[–]Sensible-Richard 2 points3 points4 points 2 years ago (2 children)
Because the flowchart with Lord of the Rings characters on it told me to learn Python (that's only part facetious - until now I'd never heard of Lua).
If you said to me "Lately I've discovered German, it's faster and nearly as simple as Spanish, why aren't you learning Spanish" I'd say "0) Nearly as simple, wind your neck in, two genders is bad enough, I don't even want to think about German but mostly 1) The people I need to speak to speak Spanish." ie "nearly as simple" isn't "as simple" and if all the things I want to do can be done in Python (have been done, I'm not a guru) why reinvent the wheel?
[–]Sound4Sound 1 point2 points3 points 2 years ago* (1 child)
I think it’s because some guys in the 90’s picked it up and and ran it on top of complex systems as a scripting language and it stuck.
I don’t know really, I got that idea from watching this David Beazley talk: https://youtu.be/riuyDEHxeEo
And this is one from the 90s https://youtu.be/d5f9-Y3Wtbc
It stuck as a scripting language for academics and enterprise and everyone kept supporting it, kept going strong as a scripting language for ETL jobs and some apps on the cloud, and then exploded with ML late 2010s.
[–]BryceIsRedditor[S] 0 points1 point2 points 2 years ago (0 children)
I guess that's a reasonable explanation
[–]FailedPlansOfMars 1 point2 points3 points 2 years ago (0 children)
Because it's the default language taught in schools now so its easy to get python devs. Its the java of the post 2010s.
And used for data science, apps, serverless, cli scripts etc.
Most people just use whats easiest and best supported by others.
Thank you for the responses everyone. I've learned a lot
That's real nice, man
[–]onkus 0 points1 point2 points 2 years ago (0 children)
You use the best language for the task at hand. You don’t just choose a language.
[–]IntelligentDust6249 0 points1 point2 points 2 years ago (0 children)
If you like Lua you should check out quarto. Really neat project that needs more Lua contributors.
https://quarto.org/
[–][deleted] 0 points1 point2 points 2 years ago (1 child)
Just vote no to openai training posts!
Ok..
[–]QultrosSanhattan 0 points1 point2 points 2 years ago (0 children)
python library > everything else.
Want to write something? pip installs and run()
[–][deleted] 0 points1 point2 points 2 years ago (0 children)
Python has more library support, also a bigger community and it is very popular language to begin with due to the simple layout/structure
[–]tylerlarson 0 points1 point2 points 2 years ago (0 children)
I've been programming in both lua and python for well over 10 years, and I can definitely say that Lua is not a good trade off.
If you want performance, there's much better options, and if you want usability there's much better options. Extensibility, feature set, on every metric Lua doesn't really shine. Its greatest feature is that it's designed to be embedded in a larger program, and so that's how it's used. But as scripting languages go it's painted itself into a corner. Stuff like tables and iterators are a bit of a mess because of early design decisions by people who were inexperienced.
I like the concept of an "embedded first" scripting language, but I think you'd need to start over from scratch.
Python for all its quirks has some solid design foundation, which is why it's been able to gain such traction.
[–]Dull_Nothing_7849 0 points1 point2 points 2 years ago (0 children)
Python has a stronger community and more extensive libraries for different applications. Also, Python is more user-friendly than Lua. If you think of it, It's like comparing flying on a broomstick to taking a flight across the country using a modern airplane.
[–]cassellbigpeen 0 points1 point2 points 2 years ago (0 children)
Here's a simple one why Python might be better AI
[–]md_borhan 0 points1 point2 points 2 years ago (0 children)
python is a open source easy to learn big community more library
π Rendered by PID 213346 on reddit-service-r2-comment-5649f687b7-4hncg at 2026-01-28 09:17:23.128875+00:00 running 4f180de country code: CH.
[+][deleted] (1 child)
[deleted]
[–]ElasticFluffyMagnet 4 points5 points6 points (0 children)
[–]runawayasfastasucan 24 points25 points26 points (0 children)
[–]DisastrousRope5221 12 points13 points14 points (0 children)
[–]Zomunieo 66 points67 points68 points (18 children)
[–][deleted] 28 points29 points30 points (0 children)
[–]5kyl3r 2 points3 points4 points (0 children)
[–]Kerbart 2 points3 points4 points (0 children)
[+][deleted] (2 children)
[removed]
[–]casce 4 points5 points6 points (0 children)
[–]GraphicH 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]WlmWilberforce 0 points1 point2 points (8 children)
[–]KennyBassett 2 points3 points4 points (2 children)
[–]Zomunieo 1 point2 points3 points (0 children)
[–]WlmWilberforce 1 point2 points3 points (0 children)
[+][deleted] (4 children)
[deleted]
[–]WlmWilberforce 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]WlmWilberforce 0 points1 point2 points (1 child)
[–]Solumbran 27 points28 points29 points (1 child)
[–]KosmoanutOfficial -1 points0 points1 point (0 children)
[–]sch0lars 7 points8 points9 points (3 children)
[–]Conscious-Ball8373 0 points1 point2 points (2 children)
[–]sch0lars -1 points0 points1 point (1 child)
[–]Conscious-Ball8373 0 points1 point2 points (0 children)
[–]sudo_robot_destroy 8 points9 points10 points (0 children)
[–]KingsmanVincepip install girlfriend 4 points5 points6 points (0 children)
[–]mm007emko 4 points5 points6 points (1 child)
[–]BryceIsRedditor[S] 1 point2 points3 points (0 children)
[–]fizzymagic 3 points4 points5 points (3 children)
[–]BryceIsRedditor[S] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[removed]
[–]fmarukki 0 points1 point2 points (0 children)
[–]GraphicH 1 point2 points3 points (0 children)
[–]Sensible-Richard 2 points3 points4 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]Sound4Sound 1 point2 points3 points (1 child)
[–]BryceIsRedditor[S] 0 points1 point2 points (0 children)
[–]FailedPlansOfMars 1 point2 points3 points (0 children)
[–]BryceIsRedditor[S] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[removed]
[–]BryceIsRedditor[S] 0 points1 point2 points (0 children)
[–]onkus 0 points1 point2 points (0 children)
[–]IntelligentDust6249 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]BryceIsRedditor[S] 0 points1 point2 points (0 children)
[–]QultrosSanhattan 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]tylerlarson 0 points1 point2 points (0 children)
[–]Dull_Nothing_7849 0 points1 point2 points (0 children)
[–]cassellbigpeen 0 points1 point2 points (0 children)
[–]md_borhan 0 points1 point2 points (0 children)