How is this differs from PEP 634 (https://docs.python.org/3.10/whatsnew/3.10.html#pep-634-structural-pattern-matching)?

On 2021. 05. 04. 20:33, Shreyan Avigyan wrote:
Most of programming languages out there have switch-case statements. Python 
doesn't have support for switch-case statements though. switch-case statements 
can sometimes be nice and tidy and sometimes it may be a horrible nightmare. 
But that also applies to if-elif-else statements. It would be nice to have 
switch-case statements support in python.

Suggested syntax :-
-------------------

switch expr:
     case expr2:
     case expr3:
         statements
     default:
         statements


How should it be implemented?
-----------------------------------

First of all this will require a new syntax. Second I suggest for comparing the 
case expr with switch expr, compare the pointers instead of objects for better 
performance. Usually if the ladder is represented using if-elif-else logic then 
it would be lower performance because we'll end up comparing objects not 
pointers.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/32SKTIZCNJP74ZJSHQ4R2R4A3ODC3LMN/
Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/DPZM6JN2VR3PUWGGQEB2FLRU5YXJGH37/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to