Earlier quoted context omitted.
It literally doesn’t matter unless it impacts users. I don’t know why you would waste time on non problems.
No one is suggesting “wasting time on non problems.” You’re tilting at windmills.
Python numbers every programmer should know
121–130 of 191 posts
Re: Python numbers every programmer should know
#122> small int (0-256) cached It's -5 to 256, and these have very tricky behavior for programmers that confuse identity and equality. >>> a = -5 >>> b = -5 >>> a is b True >>> a = -6 >>> b = -6 >>> a is b False
Re: Python numbers every programmer should know
#123A lot of people here are commenting that if you have to care about specific latency numbers in Python you should just use another language. I disagree. A lot of important and large codebases were grown and maintained in Python (Instagram, Dropbox, OpenAI) and it's damn useful to know how to reason your way out of a Python performance problem when you inevitably hit one without dropping out into another language, whic…
I think these kind of numbers are everywhere and not just specific to Python.
In zig, I sometimes take a brief look to the amount of cpu cycles of various operations to avoid the amount of cache misses. While I need to aware of the alignment and the size of the data type to debloat a data structure. If their logic applies, too bad, I should quit programming since all languages have their own latency on certain operations we should aware of.
There are reasons to not use Python, but that particular reason is not the one.
Re: Python numbers every programmer should know
#124Re: Python numbers every programmer should know
#125Re: Python numbers every programmer should know
#126Earlier quoted context omitted.
I agree. I've been living off Python for 20 years and have never needed to know any of these numbers, nor do I need them now, for my work, contrary to the title. I also regularly use profiling for performance optimization and opt for Cython, SWIG, JIT libraries, or other tools as needed. None of these numbers would ever factor into my decision-making.
..... You don't see any value in knowing that numbers?
Re: Python numbers every programmer should know
#127Earlier quoted context omitted.
Knowing that an empty string is 41 bytes or how many ns it takes to do arithmetic operations is not general knowledge.
How is it not general knowledge? How do you otherwise gauge if your program is taking a reasonable amount of time, and, if not, how do you figure out how to fix it?
P50 latency for a fastapi service’s endpoint is 30+ seconds. Your ingestion pipeline, which has a data ops person on your team waiting for it to complete, takes more than one business day to run.
Your program is obviously unacceptable. And, your problems are most likely completely unrelated to these heuristics. You either have an inefficient algorithm or more likely you are using the wrong tool (ex OLTP for OLAP) or the right tool the wrong way (bad relational modeling or an outdated LLM model).
If you are interested in shaving off milliseconds in this context then you are wasting your time on the wrong thing.
All that being said, I’m sure that there’s a very good reason to know this stuff in the context of some other domains, organizations, company size/moment. I suspect these metrics are irrelevant to disproportionately more people reading this.
At any rate, for those of us who like to learn, I still found this valuable but by no means common knowledge
Re: Python numbers every programmer should know
#128Earlier quoted context omitted.
Someone says "let's write a prototype in Python" and someone else says "are you sure we shouldn't use a a better language that is just as productive but isn't going to lock us into abysmal performance down the line?" but everyone else says "nah we don't need to worry about performance yet, and anyway it's just a prototype - we'll write a proper version when we need to"... 10 years later "ok it's too slow; our options…
What language is “just as productive but isn't going to lock us into abysmal performance down the line”? What makes that language not strictly superior to Python?
Re: Python numbers every programmer should know
#129If I have only plain Python installed and a .py file that I want to test, then what's the easiest way to get a visualization of the call tree (or something similar) and the computational cost of each item?
Re: Python numbers every programmer should know
#130Earlier quoted context omitted.
How is it not general knowledge? How do you otherwise gauge if your program is taking a reasonable amount of time, and, if not, how do you figure out how to fix it?
In my experience, which is series A or earlier data intensive SaaS, you can gauge whether a program is taking a reasonable amount of time just by running it and using your common sense. P50 latency for a fastapi service’s endpoint is 30+ seconds. Your ingestion pipeline, which has a data ops person on your team waiting for it to complete, takes more than one business day to run. Your program is obviously unacceptable…
In my experience writing computer vision software, people really struggle with the common sense of how fast computers really are. Some knowledge like how many nanoseconds an add takes can be very illuminating to understand whether their algorithm's runtime makes any sense. That may push loose the bit of common sense that their algorithm is somehow wrong. Often I see people fail to put bounds on their expectations. Numbers like these help set those bounds.