Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9577 > unrolled thread

Re: Python ++ Operator?

Started byChris Angelico <rosuav@gmail.com>
First post2011-07-16 08:51 +1000
Last post2011-07-16 14:25 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Python ++ Operator? Chris Angelico <rosuav@gmail.com> - 2011-07-16 08:51 +1000
    Re: Python ++ Operator? Adam Przybyla <adam@rybnik.pl> - 2011-07-16 14:25 +0000

#9577 — Re: Python ++ Operator?

FromChris Angelico <rosuav@gmail.com>
Date2011-07-16 08:51 +1000
SubjectRe: Python ++ Operator?
Message-ID<mailman.1085.1310770297.1164.python-list@python.org>
On Sat, Jul 16, 2011 at 6:26 AM, Dan Stromberg <drsalists@gmail.com> wrote:
>
> I don't regard this as a low level versus VHLL issue - I regard it as a
> matter of operators with side effects being too error prone.  Adding such
> operators to Python has been discussed (it'd almost certainly be easy to
> add), and rejected.

It's not that it has or has not, due to its highness of level, but
more a needs or needs not. In Python, iterating over an array is done
with a for loop and the array's own iterator (or enumerate() if you
need the indices), but C doesn't have iterators, so it needs a
convenient notation for incrementing through the array.

> BTW, array operations optimize to the same thing as pointer arithmetic in
> most C compilers, but the latter tends to be less clear.

I'm not fully convinced; there are many times when incrementing
pointers allows for much cleaner code. However, we are talking about
the readability of C among Python programmers. Personally, I find
pointer-dereference-and-post-increment to be perfectly readable, but
it's a construct that I use practically on a daily basis. To someone
who's not familiar with Python, list comps could suffer from the same
issues - what does THIS do? oh.

Chris Angelico

[toc] | [next] | [standalone]


#9623

FromAdam Przybyla <adam@rybnik.pl>
Date2011-07-16 14:25 +0000
Message-ID<ivs70v$f80$1@polsl.pl>
In reply to#9577
Chris Angelico <rosuav@gmail.com> wrote:
> On Sat, Jul 16, 2011 at 6:26 AM, Dan Stromberg <drsalists@gmail.com> wrote:
>>
>> I don't regard this as a low level versus VHLL issue - I regard it as a
>> matter of operators with side effects being too error prone.  Adding such
>> operators to Python has been discussed (it'd almost certainly be easy to
>> add), and rejected.
> 
> It's not that it has or has not, due to its highness of level, but
> more a needs or needs not. In Python, iterating over an array is done
> with a for loop and the array's own iterator (or enumerate() if you
> need the indices), but C doesn't have iterators, so it needs a
> convenient notation for incrementing through the array.
> 
>> BTW, array operations optimize to the same thing as pointer arithmetic in
>> most C compilers, but the latter tends to be less clear.
> 
> I'm not fully convinced; there are many times when incrementing
> pointers allows for much cleaner code. However, we are talking about
> the readability of C among Python programmers. Personally, I find
> pointer-dereference-and-post-increment to be perfectly readable, but
> it's a construct that I use practically on a daily basis. To someone
> who's not familiar with Python, list comps could suffer from the same
> issues - what does THIS do? oh.
	list_ptr=list_a
	list_ptr=list_ptr[1:]
Regards
								Adam Przybyla

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web