Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@620hun I'm not joking. The bigger problem was the Django query method, which activate a lot of DB queries..
-
@foobarabba yeah another classic example of devs relying too much on 3rd party libs... gotta go native, otherwise your not an engineer, your just some guy that knows how to use tools. But what happens when those tools breakdown, or worse, break your shit? On a side note, I'm guessing you can solve by running the Django query on a background thread. Or perhaps doing some native indexing of the database. Or maybe just finally realizing that you shouldn't ever be 'SELECTING ALL', you lazy lazy programmer!
-
@greenhouse
Yes, and this situation is everywhere in the app code.. because it's a matter of approach to problem solving. If the programmer need only 'things done' and no performance and reusability..that is what happens.
Try to modify the code now..and see if you can do it easly! -
@rtannerf yeah, if his query for all rows is embedded in those loops. This will certainly slow things down for him. Especially if he has base64 data in the columns for some reason, that would make it even worse. Whatever his 8 loop algorithm is, it's going to run 0 -> x times. A more efficient algorithm will probably speed things up, but ultimately it's what's being executed inside those loops that is taking up time. He first needs to look and understand what it is that being executed, then he can debug the algorithm.
-
Python slow only in stupid's hand.
If is slow even in the expert hand, then you need Cython, who are approx 300 times more fast of a C handwritten program (tested on a Fibonacci's generator)
In all the code I've watched, the worst boost is of X10 than C.
And the syntax is Python :3 -
@eisterman
I agree with you, mine was sarcasm.
I love python and I definitely don't think it's slow! -
github95487yMay be your friend is just starting up with Python.. Give him the much needed enlightenment..
Once, I did somewhat similar idiotic stuff, was preprocessing a CSV file with nested loops and took me 2 days for the program to finish with a parse error in halfway of preprocessing...
Later, a Pythonic friend of mine gave me suggestions (in memory dictionary instead of heavy file operations), and it got over in seconds..
That's how we evolve I guess.. We as devs, should bare sometimes the silly mistakes done by our friends or colleagues and help them until n unless they are stubborn enough to not change.. -
github95487y@foobarabba once during Internship, 2 juniors were developing an API that was to be integrated as the backend logic...
The 2 greatest thing they did are:
1. Every f**king time, the code accesses the DB, it creates a new connection.. sometimes these new connections are created inside nested loops.. Now imagine the number of DB objects..
2. As I mentioned, it was an API meant for backend integration, and the entire code was not modular in a single main function and all Inputs were passed through terminal..
Note: Those 2 were noobs that time.. now, I definitely believe they got experience.. Just got to know 1 of them got selected for Google as Intern.. way to go..
Moral: Never be afraid to do silly or crazy mistakes, at the end you learn from yourself or by others based on these mistakes... -
@github
I understand.
But the programmer we are talking about has 10 years of experience.
So it is only a matter of "code style" and "to be professional or not". -
OrestH7487yJust tell me how can somebody use 8 nested loops? It is just the baddest code I've ever heard
And blaming the language for your bad code is so childish -
for blah in blahs:
ModelfetchRedundantlyOverAndOver.all()
for crap in poo:
ModelFetchMoreResourcesFromDBUnecessarilyToMakePythonSlow.all() -
@eisterman cython cannot be faster than well written c-code. C compiles to native instructions for the processor.
-
@foobarabba @papierbouwer But is hard make good C code!
Cython compile Python into a good written C code, sometimes faster than hand-written C code for the same problem
That's the true power of Cython -
@eisterman well, maybe cython approaches the Python coder to C coder. But the latter, if good, is almost unattainable. How many really really good C coders have been around?
-
@eistermann @foobarabba and both cannot beat good written assembly. It will always remain the most efficient. But very complex to write ofcourse.
-
@papierbouwer @foobarabba at last the most important think is the result, the tim used and the difficulty of maintaining.
Recently I found that Numpy, Scipy and all the principal science module for Python are written in Cython, and the result is VERY satisfactory
Related Rants
Colleague: "Python is slow..too much slow."
Then I look at the code:
Eight nested for loops, inside two of them, two function calls and three list comprehension. That function has 2 nested loops and two "objects.all()" Django method, plus a list comprehension too..
Yep, Python is slow.
undefined
colleagues givemeheadache
programming
python
code style