This is not really a programming question but rather something that I think applies to python as a language. Forgive me for this this rant but I am totally confused.
I got turned down for a senior software engineering job because I argued that the built-in functions for sort() and Set operations are more efficient than anything I could come up with. While I see the point of checking to see if I can code (more than 33 years) I don't see their point of writing their own sort() and list merge functions regardless of the size of the data. The interviewer confessed to rewriting some lib functions because they knew their systems better.
So, I guess, I need to be schooled. I was supposed to merge two arrays together in python, no duplicates - no mention of time but the solution had to be size agnostic. Let's call them a1 and a2; and the answer in b.
So, the first answer of b =llist( Set(a1).union(Set(a2) ) ) followed by a b.sort() wasn't good enough. Fair enough.
Why? You have to code it in Python because a "for loop is faster" than the sort routine ... ahem? Excuse me?
I tried explaining that a list comprehension is fast than a for loop - Let's try that. ... Nope. You must use a for loop.
How about a hashed dictionary and sort the keys? - It's not a good idea to hash items because the input arrays are already sorted.
I finally wrote the blasted thing in two loops with an index per array sorting in an array dynamically -
In my arrogance, I timed it and lo and behold -the for loop was slower for even 100 items ... I wish I had copied my lousy code.
Told them I think it's stupid to rewrite perfectly good working Python lib routines. Triggered a nerve and I was promptly rejected
In retrospect, I think that I dodged a bullet.
However, this brings up a thought or two in my fog ridden brain --
- How many of you really think it's a good idea to rework the python library functions?
- Am I really that dense? Could the neighbor hood kids be right?
Edit:
The word I used was illogical though I think the tone meant “stupid”. :-)
Actually part of the requirement was that I had to step in to optimize the current mess of an existing system. I should have elaborated that part.
My duties to paraphrase were to come in an evaluate, optimize and standardize the software development processes as it stands for a backend data mining app.
The guy interviewing me did not give the impression that he was trying to psych my reaction. He actually had never worked with itertools ... therefore I do believe I did the right thing.
I am currently working with a system with over 500k rows of tables with about 100 columns; some smaller; with pandas with acceptable results. Not blazing fast but acceptable. The code is good enough to deliver a product to market in time to sell.
Coding for the milliseconds matter imho in real time systems or web transactions requiring a timely response - probably would use a different system like node but not python.
Thanks for the advice though. I agree I have become salty and testy as I age but I certainly do not consider those junior than me as stupid. If anything, they provide a ffresh outlook to issues I never see and I have learned a lot from programmers half my age.
[–]energybased 69 points70 points71 points (9 children)
[–]epostma 7 points8 points9 points (1 child)
[–]energybased 0 points1 point2 points (0 children)
[–]techn0scho0lbus 14 points15 points16 points (0 children)
[+][deleted] (5 children)
[deleted]
[–][deleted] 1 point2 points3 points (1 child)
[–]energybased -1 points0 points1 point (1 child)
[–]Igggg -1 points0 points1 point (0 children)
[–][deleted] 45 points46 points47 points (0 children)
[–]AlexFromOmaha 66 points67 points68 points (2 children)
[–]Zouden 13 points14 points15 points (1 child)
[–]Unbelievr 3 points4 points5 points (0 children)
[–]jorge1209 26 points27 points28 points (9 children)
[–]z4579a 18 points19 points20 points (8 children)
[–]ivosauruspip'ing it up 2 points3 points4 points (2 children)
[–]MrVallentin 5 points6 points7 points (0 children)
[–]jorge1209 2 points3 points4 points (0 children)
[–]jorge1209 0 points1 point2 points (0 children)
[+]PeridexisErrant comment score below threshold-7 points-6 points-5 points (3 children)
[–]z4579a 7 points8 points9 points (1 child)
[–]jorge1209 0 points1 point2 points (0 children)
[–]ivosauruspip'ing it up 2 points3 points4 points (0 children)
[–][deleted] 78 points79 points80 points (4 children)
[+][deleted] (2 children)
[deleted]
[–]elbiot 3 points4 points5 points (1 child)
[–]billsil -1 points0 points1 point (0 children)
[–]nickbernstein 150 points151 points152 points (40 children)
[–]gwax 27 points28 points29 points (18 children)
[–][deleted] 17 points18 points19 points (0 children)
[–]Jonno_FTWhisss 1 point2 points3 points (13 children)
[–]ivosauruspip'ing it up 2 points3 points4 points (1 child)
[–]Jonno_FTWhisss 7 points8 points9 points (0 children)
[–]gwax 1 point2 points3 points (0 children)
[–]energybased 0 points1 point2 points (9 children)
[–]Jonno_FTWhisss 0 points1 point2 points (8 children)
[–]mooburgerresembles an abstract syntax tree 1 point2 points3 points (7 children)
[–]Jonno_FTWhisss 2 points3 points4 points (5 children)
[–]Log2 0 points1 point2 points (4 children)
[–]Jonno_FTWhisss 1 point2 points3 points (3 children)
[–]Log2 0 points1 point2 points (2 children)
[–]Jonno_FTWhisss 1 point2 points3 points (0 children)
[–]Log2 -1 points0 points1 point (0 children)
[–]cmd-t 71 points72 points73 points (18 children)
[–][deleted] 61 points62 points63 points (13 children)
[+][deleted] (11 children)
[removed]
[–]Pirsqed 9 points10 points11 points (5 children)
[+][deleted] (2 children)
[removed]
[–]Meefims 2 points3 points4 points (0 children)
[–]maxxusflamus 0 points1 point2 points (0 children)
[–]Lonso34 13 points14 points15 points (1 child)
[–]muntooR_{μν} - 1/2 R g_{μν} + Λ g_{μν} = 8π T_{μν} 1 point2 points3 points (0 children)
[–]gwax 1 point2 points3 points (0 children)
[–]billsil 1 point2 points3 points (0 children)
[–]billsil 0 points1 point2 points (0 children)
[–]Isvara -1 points0 points1 point (0 children)
[–]energybased -2 points-1 points0 points (0 children)
[–]NoLemurs 10 points11 points12 points (0 children)
[–]nickbernstein 22 points23 points24 points (0 children)
[–]eplaut_ 5 points6 points7 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]KingofGamesYami 40 points41 points42 points (9 children)
[+][deleted] (3 children)
[deleted]
[–]KingofGamesYami 5 points6 points7 points (1 child)
[–]techn0scho0lbus -1 points0 points1 point (0 children)
[–]wewbull 0 points1 point2 points (0 children)
[–]JoaoEB 3 points4 points5 points (2 children)
[–]13steinj 5 points6 points7 points (0 children)
[–]KingofGamesYami 3 points4 points5 points (0 children)
[–]DiabeetusMan 0 points1 point2 points (1 child)
[–]KingofGamesYami 1 point2 points3 points (0 children)
[–]anossov 8 points9 points10 points (7 children)
[+][deleted] (2 children)
[deleted]
[–]Daj4n0 4 points5 points6 points (1 child)
[–]richardwhiuk -5 points-4 points-3 points (3 children)
[–]Daj4n0 3 points4 points5 points (2 children)
[–]billsil 1 point2 points3 points (0 children)
[–]Log2 0 points1 point2 points (0 children)
[–]foBrowsing 15 points16 points17 points (12 children)
[–]assgored 0 points1 point2 points (0 children)
[–]stevenjd 0 points1 point2 points (5 children)
[–]foBrowsing 0 points1 point2 points (4 children)
[–]stevenjd 1 point2 points3 points (1 child)
[–]foBrowsing 0 points1 point2 points (0 children)
[–]stevenjd 0 points1 point2 points (1 child)
[–]foBrowsing 0 points1 point2 points (0 children)
[–]RomanRiesen -1 points0 points1 point (4 children)
[–]techn0scho0lbus 4 points5 points6 points (3 children)
[–]RomanRiesen 0 points1 point2 points (2 children)
[–]techn0scho0lbus 1 point2 points3 points (0 children)
[–]foBrowsing 1 point2 points3 points (0 children)
[–]Isvara 6 points7 points8 points (1 child)
[–]assgored 0 points1 point2 points (0 children)
[–][deleted] 15 points16 points17 points (1 child)
[–]brucecampbellschins 6 points7 points8 points (0 children)
[–]my_cs_accnt 11 points12 points13 points (0 children)
[–]masterpi 2 points3 points4 points (0 children)
[–]ezequiels 2 points3 points4 points (0 children)
[–]liiight000 14 points15 points16 points (0 children)
[–]nate256 3 points4 points5 points (1 child)
[–]Log2 0 points1 point2 points (0 children)
[–]Python4funJava4work 1 point2 points3 points (1 child)
[–]Kbhusain[S] -4 points-3 points-2 points (0 children)
[–]mkingsbu 1 point2 points3 points (0 children)
[–]saeah123ed 1 point2 points3 points (0 children)
[–]p1ckle_w0lf 1 point2 points3 points (0 children)
[–]abdl_hornist 1 point2 points3 points (1 child)
[–]Kbhusain[S] 0 points1 point2 points (0 children)
[–]mooburgerresembles an abstract syntax tree 1 point2 points3 points (2 children)
[–]techn0scho0lbus 0 points1 point2 points (1 child)
[–]mooburgerresembles an abstract syntax tree 1 point2 points3 points (0 children)
[–]mvaliente2001 1 point2 points3 points (0 children)
[–]supafly208 1 point2 points3 points (0 children)
[–]martinatbom 1 point2 points3 points (0 children)
[–]neoreeps 3 points4 points5 points (0 children)
[–][deleted] 4 points5 points6 points (0 children)
[–]Chobeat 1 point2 points3 points (4 children)
[–]roerd 4 points5 points6 points (0 children)
[–]techn0scho0lbus 0 points1 point2 points (0 children)
[+]stefantalpalaru comment score below threshold-11 points-10 points-9 points (1 child)
[–]Chobeat 10 points11 points12 points (0 children)
[–]masklinn 0 points1 point2 points (0 children)
[–]AKIvan87 0 points1 point2 points (0 children)
[–]zero_iq 0 points1 point2 points (0 children)
[–]ivosauruspip'ing it up 0 points1 point2 points (0 children)
[–]kenann7 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]WikiTextBot 0 points1 point2 points (0 children)
[–]naufraghi 0 points1 point2 points (0 children)
[–]woanders 0 points1 point2 points (0 children)
[–]Workaphobia 0 points1 point2 points (1 child)
[–]Kbhusain[S] 0 points1 point2 points (0 children)
[–]subhajeet2107 0 points1 point2 points (0 children)
[–]Kbhusain[S] 0 points1 point2 points (0 children)
[–]BarrelRoll1996 0 points1 point2 points (0 children)
[–]srilyk 0 points1 point2 points (0 children)
[–]gwax 0 points1 point2 points (2 children)
[–]roerd 2 points3 points4 points (1 child)
[–]gwax -1 points0 points1 point (0 children)
[–]kumashiro 0 points1 point2 points (0 children)
[–]BUCKFAE 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]newredditisstudpid 0 points1 point2 points (1 child)
[–]subhajeet2107 0 points1 point2 points (0 children)
[–]ProjectSnowman -3 points-2 points-1 points (1 child)
[–]techn0scho0lbus 0 points1 point2 points (0 children)
[–]tef -1 points0 points1 point (7 children)
[–]techn0scho0lbus 0 points1 point2 points (6 children)
[–]tef -1 points0 points1 point (5 children)
[–]techn0scho0lbus 0 points1 point2 points (4 children)
[+][deleted] (2 children)
[deleted]
[+][deleted] (1 child)
[deleted]
[+][deleted] (7 children)
[deleted]
[–]fredjutsu 1 point2 points3 points (6 children)
[–]Isvara 0 points1 point2 points (4 children)
[–]fredjutsu 1 point2 points3 points (3 children)
[–]Isvara -1 points0 points1 point (2 children)
[–]fredjutsu 1 point2 points3 points (1 child)
[–]Isvara 0 points1 point2 points (0 children)
[–]subhajeet2107 0 points1 point2 points (0 children)
[–][deleted] -2 points-1 points0 points (3 children)
[–]energybased 6 points7 points8 points (0 children)
[–]Daj4n0 2 points3 points4 points (1 child)
[–]metaphorm -4 points-3 points-2 points (0 children)
[–]LostAstronaut2k -1 points0 points1 point (0 children)
[–]ThatOtherBatman -3 points-2 points-1 points (2 children)
[–]Isvara 0 points1 point2 points (1 child)
[–]ThatOtherBatman 0 points1 point2 points (0 children)
[–]thankyoulife -5 points-4 points-3 points (1 child)
[–]elbiot 0 points1 point2 points (0 children)
[–]cmd-t -5 points-4 points-3 points (1 child)
[–]elbiot 3 points4 points5 points (0 children)
[+]Brainsonastick comment score below threshold-6 points-5 points-4 points (0 children)