Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.023 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'python,': 0.02; 'operator': 0.03; 'cc:addr:python-list': 0.11; 'before.': 0.16; 'debated': 0.16; 'from:addr:xavierho.com': 0.16; 'from:name:xavier ho': 0.16; 'notation.': 0.16; 'readability': 0.16; 'sender:addr:spaxe85': 0.16; 'subject:API': 0.16; 'subject:Object': 0.16; 'subject:oriented': 0.16; 'component': 0.16; 'sender:addr:gmail.com': 0.17; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; '>>>': 0.24; 'forms.': 0.24; 'mathematical': 0.24; 'simpler': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'class.': 0.26; 'header:In- Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'said,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'idea,': 0.31; 'there.': 0.32; 'probably': 0.32; 'agree': 0.35; 'something': 0.35; 'definition': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'c++': 0.36; 'done': 0.36; 'two': 0.37; 'anything': 0.39; 'bad': 0.39; 'most': 0.60; 'matter': 0.61; 'skip:6 10': 0.63; 'more': 0.64; 'love': 0.65; 'subject:. ': 0.67; 'between': 0.67; 'header:Reply- To:1': 0.67; 'believe': 0.68; 'products': 0.71; 'reply-to:no real name:2**0': 0.71; 'max,': 0.84; 'overloading': 0.84; 'reply- to:addr:contact': 0.84; 'choice.': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:reply-to:sender:in-reply-to:references:from :date:x-google-sender-auth:message-id:subject:to:cc:content-type; bh=RMoB8EHzD3VI7ZQ8/9pLUeGjI4/v7AL5V7SDSFUxkeY=; b=yGCYT/TfYkKz+QeGncUYeziy4+N8MLzm5b+89Dv9CutGTucUuUneSp8GMgubBZhojc i6qpe9D4epQrjfhwGVUufXyjwIQcO95gQuN5WYrckRp7XNDP/stlXLyUlteu6AiyI2RY ZHbIAbfZdgmYPZPGcJvJyrvF6xN6XxG9Es02hOm018LKuDTiQosEj2/iMuHfswn1jsQs m14uwDwzy43juy1tsDZR6KBcvLENG91qLcS71Tu8ChTaOs4dL/IMWskGVE+jCov106ff F5c/9+I2oaweI/MGkS393NEXrbzCJl7ShsCNU6kRHPvaOEVebPmL9NRbQKoH2AfUYflM kbPg== X-Received: by 10.58.29.101 with SMTP id j5mr3296465veh.26.1365636448381; Wed, 10 Apr 2013 16:27:28 -0700 (PDT) MIME-Version: 1.0 Sender: spaxe85@gmail.com In-Reply-To: References: From: Xavier Ho Date: Thu, 11 Apr 2013 09:27:08 +1000 X-Google-Sender-Auth: 1ALxYj0U4bsC97vsjvcH-Ut0o80 Subject: Re: Functional vs. Object oriented API To: Max Bucknell Content-Type: multipart/alternative; boundary=047d7b67656266239304da0a03ee Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: contact@xavierho.com List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 74 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365636451 news.xs4all.nl 2632 [2001:888:2000:d::a6]:34016 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43303 --047d7b67656266239304da0a03ee Content-Type: text/plain; charset=UTF-8 Hi Max, In Python, we prefer readability over anything else. The simpler you can write it, the better it can be understood. That said, I've never considered using (i, j, k) as a vector component before. I've always done something akin to: >>> vector = Vector(2, 4, 6) >>> print (vector.normalize().y) However, if you use the mathematical definition of a vector, with standard symbols: v = x*i + y*j + z*k Then I believe vector.j is a much choice. As long as your documentation states it's read-only, I think most mathematicians will love that notation. . As far as dot products go, there isn't really a big difference between the two forms you have there. Both are equally as readable. When C++ was invented people had already debated about the two forms. There isn't a general consensus on this debate, but most would probably agree that overloading the * operator of a vector to do dot product is a bad idea, since some people want cross product, or per-component multiplication. At the end of the day, dot() or dot_product() is more readable, and it doesn't matter if you have it as a function in or outside of a vector's class. Cheers, Xav --047d7b67656266239304da0a03ee Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Max,

In Python, we prefer readabilit= y over anything else. =C2=A0The simpler you can write it, the better it can= be understood.

That said, I've never consider= ed using (i, j, k) as a vector component before. =C2=A0I've always done= something akin to:

>>> vector =3D Vector(2, 4, 6)
>&= gt;> print (vector.normalize().y)

However= , if you use the mathematical definition of a vector, with standard symbols= :

=C2=A0 =C2=A0 v =3D x*i + y*j + z*k

Then I believe vector.j is a much choice. =C2= =A0As long as your documentation states it's read-only, I think most ma= thematicians will love that notation.

.

As f= ar as dot products go, there isn't really a big difference between the = two forms you have there. =C2=A0Both are equally as readable.

When C++ was invented people had already debated about= the two forms. =C2=A0There isn't a general consensus on this debate, b= ut most would probably agree that overloading the * operator of a vector to= do dot product is a bad idea, since some people want cross product, or per= -component multiplication. =C2=A0At the end of the day, dot() or dot_produc= t() is more readable, and it doesn't matter if you have it as a functio= n in or outside of a vector's class.

Cheers,
Xav
--047d7b67656266239304da0a03ee--