dgz
Supreme [H]ardness
- Joined
- Feb 15, 2010
- Messages
- 5,838
Here's something you don't read every day. It reminded me of that YT: Jim Keller: Moore’s Law is Not Dead video where, among other interesting things, he also shared his views about abstractions and how they're not inherently bad.
This is especially hilarious to me since just yesterday my boss was ranting about his recent experience with Python and how it's literally the worst language he has ever seen. "Everything about it is an anti pattern"
Source: https://blogs.oracle.com/solaris/re...hon-gained-17x-performance-improvement-from-c
This is especially hilarious to me since just yesterday my boss was ranting about his recent experience with Python and how it's literally the worst language he has ever seen. "Everything about it is an anti pattern"
The C code was largely untouched since 1988 and was around 800 lines long, it was written in an era when the number of users was fairly small and probably existed in the local files /etc/passwd or a smallish NIS server.
It turns out that the algorithm to implement the listusers is basically some simple set manipulation. With no arguments listusers just dumps a sorted list of all users in the nameservice, with the -l and -g it filters down the list of users and groups.
My rewrite of listusers in Python 3 turned out to be roughly a 10th of the number of lines of code - since Python includes native set manipulation and the C code had implemented the set operations it via linked lists.
But Python would be slower right ? Turns out it isn't and in fact for some of my datasets (that had over 100,000 users in them) it was 17 times faster. I also made sure that the Python version doesn't pull the entire nameservice into memory when it knows it is going to be filtering it based on the -l and -g options.
Source: https://blogs.oracle.com/solaris/re...hon-gained-17x-performance-improvement-from-c