Jul-12-2020, 12:32 AM
i don't have any code handy that i can show. i'll try to describe something simple. a one place in the elif sequence i want to test a string for an '=' character. if it does have an '=' in it, i also want to test for the part before the '=' being in a dictionary. so it would look like
if the compiler phase optimized well, it could see that split is done twice with like args and make the run time p-code that does the split just once. then i would not worry about it. gcc has very good optimization of cases like that. but i really don't know what i get out of CPython.
elif '=' in my_string and my_string.split('=',1)[0] in magic_keys:that works but i also want the part after the '=', so
key,value = mystring.split('=',1)is going to be done, somewhere. i'd like to do the split only one time. in C it is easy to save results and test them. so i end up making code that does things twice.
if the compiler phase optimized well, it could see that split is done twice with like args and make the run time p-code that does the split just once. then i would not worry about it. gcc has very good optimization of cases like that. but i really don't know what i get out of CPython.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.