Python Forum
two conditionals with intermediate code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
two conditionals with intermediate code
#3
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
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.
Reply


Messages In This Thread
RE: two conditionals with intermediate code - by Skaperen - Jul-12-2020, 12:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Doubt about conditionals in Python. Carmazum 6 1,666 Apr-01-2023, 12:01 AM
Last Post: Carmazum
  conditionals based on data frame mbrown009 1 925 Aug-12-2022, 08:18 AM
Last Post: Larz60+
  Efficiency with regard to nested conditionals or and statements Mark17 13 3,266 May-06-2022, 05:16 PM
Last Post: Mark17
  Nested conditionals vs conditionals connected by operators dboxall123 8 3,126 Feb-18-2022, 09:34 PM
Last Post: dboxall123
  Nested Conditionals shen123 3 2,669 Jul-28-2021, 08:24 AM
Last Post: Yoriz
  Invalid syntax using conditionals if - else jperezqu 1 2,362 Jan-13-2021, 07:32 PM
Last Post: bowlofred
  conditionals with boolean logic?? ridgerunnersjw 3 2,026 Sep-26-2020, 02:13 PM
Last Post: deanhystad
  Conditionals, while loops, continue, break (PyBite 102) Drone4four 2 3,023 Jun-04-2020, 12:08 PM
Last Post: Drone4four
  Nested Conditionals HELP absolum 4 2,824 Jul-17-2019, 06:40 PM
Last Post: absolum
  intermediate book recommendation please? jameson984 1 2,058 Jul-15-2019, 03:21 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020