On 23/03/2016 23:55, Steven D'Aprano wrote:
On Thu, 24 Mar 2016 03:24 am, Random832 wrote:

On Wed, Mar 23, 2016, at 12:08, Mark Lawrence wrote:
And doing it 'Pythonically' can lead to suggestions such as the
following the other day:

   c, psource = psource[0], psource[1:]

(where psource is a very long string), which even I could tell, from
knowing what goes on behind the scenes, wasn't going to work well
(duplicating the rest of the string roughly every other character).


It would work perfectly. How would it duplicate the rest of the string
roughly every other character?

Er, I think he's suggesting that this would be in an inner loop
(something like while psource: c, psource = psource[0], psource[1:]).
What I'm not sure of is why he thinks this is pythonic.

Because somebody here (Dennis) criticised his earlier code for passing "your
entire source string along with the character from it to the function", and
suggested splitting the string into its head and tail instead. Dennis' code
started:

         while psource:
                 c, psource = psource[0], psource[1:]
                 lxsymbol = disptable[min(ord(c), 256)](c, psource)


But one positive: this conclusively proves that "Pythonic" is in the eye of
the beholder. Dennis thinks that c, psource = psource[0], psource[1:] is
reasonable Python code; you think it's not ("I'm not sure why [Bart] thinks
this is pythonic").

Pythonic or not, Bart is correct to be concerned about the performance,

Where and when did he ever say anything about performance with respect to the above piece of code?

--
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

Reply via email to