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
-
Parzi88335y@magicMirror if you're dumb, yes. it's not meant to error trap and get fancy, it's meant to do the thing, as is TOTALLY PROPER to teach as habit!
-
Show me benchmarks of this. You're (again) throwing your third grader python oneliners around you telling us about your shitass teachers.
Check the facts you dingus. -
Parzi88335y@nitwhiz i mean, i'm not entirely sure how %timeit works and how to actually invoke it properly, plus the comparison is one line against like 12 or 13
-
Python Rules:
If it takes more than 10 lens your doing it wrong.
If your using more than a couple of variables your doing it wrong.
Learn the language.
Edit:
https://youtube.com/watch/... -
@Parzi how about you do 3-5 runs of it via unix `time`? Since were going for thousands of nanoseconds here. Because the interesting thing is not just that part of your code. Interesting would be how long the engine needs to start up, parse and run your script and cleanup + shutdown with once your oneliner, once with some variables and readability.
-
Im gonna go ahead and say that concatenation is probably slower than whatever pythons version of templating is
-
@Parzi literally the only way to say that it's faster is to provide benchmarks. Otherwise because even Python has a compile step and a rudimentary optimizer and an interpreter that uses several tricks to go faster than naive interpretation, you really can't say anything about performance (unless it's something really obvious or you really, really know your shit).
A one liner isn't much different from a program with variables for even a halfway smart compiler/interpreter. Plus this is a trivial program.
Numbers, please. -
@Parzi `time python shitcode.py` and then `time python readable.py` both multiple times, take the median of the results of the runs for each, you have it.
Given, python code is run by `python code.py`. If not, I really don't get why this engine is even used. -
Parzi88335y@TheCommoner282 it's python, anything needing any amount of heavy lifting is gonna be slow as balls. Hopefully, with decent code juggling, slightly less so...
-
Parzi88335y@TheCommoner282 C will outmuscle Python at anything complex and we both know it. I've managed to optimize an MD5 collision engine I wrote to the best of my ability, and any file size over 32 bytes or so is amazingly slow. Couple hundred tries/sec isn't shit when you've got several quintillion or more on a 3GHz CPU. (Granted, if threading in Python wasn't garbage, it'd be a lot better, but y'know...)
it's so optimized i'm even using spooled RAM to read/write each try as fast as possible, and i'm playing odds by using PRNG fill instead of sequential data as it's statistically more likely to be whatever the PRNG spits out than a fuckton of empty space and then like 4 bytes of data.
The same engine in C would probably be pulling millions of tries per second at 32 bytes, with threading.
i'm making my python prof wanna strangle me again, it's 100% the same as the example output, for those wondering why i do this to him it's because he said he "favors speed over readability" so i'm doing as he asks
code:
print("\nThe cost of the item is "+str((float(input("Enter the retail value: "))/(1+float(input("enter the markup percentage (e.g. 0.9): ")))))+"\n\nEnd of Report")
rant