On 14/03/2016 23:56, BartC wrote:
On 14/03/2016 23:19, Mark Lawrence wrote:
On 14/03/2016 22:40, BartC wrote:
Was that in Python? It was /supposed/ to be dreadful. I was making a
case for it to be supported directly.
You mean the huge great long list of hard coded function calls. They
are directly supported. So is the loop. Anything wrong with the Paul
Rubin response?
I tried it. It wasn't bad, but still 1/3 the speed of an if-elif chain
with discrete range-checking.
I still haven't seen the profile that I asked for, so I've no idea what
is taking the time.
And as my earlier link showed you often simply don't
need a switch statement in an OO language. Not much point providing
something, much worse optimising it, if it isn't needed in the first
place?
I disagree. And presumably so do others as there are so many different
attempts to implement switch, with varying degrees of success. Here's
how I do it outside Python:
switch c
when 'A'..'Z','a'..'z','_' then
++name
when '0'..'9' then
++numeric
when "()[]<>{}" then
++brackets
else
++other
end
Anything so terrible about that that Python needs to keep well clear of
or that you think its users should be deprived of?
Yes, it is not even valid Python. Switch has been rejected via at least
one PEP and from what I see it adds nothing to the language, so let's
deprive it from people who clearly don't need it in the first place.
Sorry, I'm not going to do that, and I don't expect anyone here to have
to do so either. You will have to take my posts as they are.
Drivel. Any establised member of this community, or any other community
for that matter, will always publish, unless, like the RUE, they've got
something to hide. So you're just a chicken. Where do you buy the
paint from for the streaks down your back?
OK, we've got another Rod Speed! He also gets a kick out of being rude
and insulting to everyone.
I am only rude to people such as yourself who refuse to provide code, in
fact anything, to support your case. Your "benchmark" for the switch
was yet another laughable farce, which only tested the function calls,
building tuples, running loops, there was nothing to test with respect
to the actual switch which was meant to be tested. So just in case you
missed it above, where is the profile for this test? Do you even know
what a profile is?
on the grounds that speed simply is not
the sole criteria for a language.
I agree with you. But once you've got the language right, then there's
no harm looking at performance. A switch statement like the above can be
executed in a single byte-code.
Really? Then please show us all just how it can be done via a patch to
the cPython code on the bug tracker.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
--
https://mail.python.org/mailman/listinfo/python-list