Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.06; '*not*': 0.07; 'completeness': 0.07; 'rename': 0.07; 'converted': 0.09; 'historically': 0.09; 'received:155': 0.09; 'seemed': 0.09; 'subject:()': 0.09; 'python': 0.11; 'jan': 0.12; 'assume': 0.14; '2.7': 0.14; 'question.': 0.14; 'changes': 0.15; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'hashed': 0.16; 'illustrates': 0.16; 'indirectly': 0.16; 'iterables': 0.16; 'iterated': 0.16; 'iterator': 0.16; 'keys.': 0.16; 'libraries.': 0.16; 'once.': 0.16; 'preserved': 0.16; 'received:155.180': 0.16; 'received:159': 0.16; 'received:159.53': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'reedy': 0.16; 'renaming': 0.16; 'securities,': 0.16; 'stuff,': 0.16; 'there...': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'ignore': 0.16; 'wrote:': 0.18; '3.0': 0.19; 'replacing': 0.19; 'to:name:python-list@python.org': 0.22; '2.x': 0.24; 'replace': 0.24; 'decide': 0.24; 'question': 0.24; 'developers': 0.25; 'equivalent': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'array': 0.29; 'thus': 0.29; 'needed.': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'easier': 0.31; '3.x': 0.31; 'context.': 0.31; 'lists?': 0.31; 'operations.': 0.31; 'received:169.254': 0.32; 'stuff': 0.32; 'run': 0.32; 'url:python': 0.33; 'updated': 0.34; 'sense': 0.34; 'possible.': 0.35; 'case,': 0.35; 'operations': 0.35; 'but': 0.35; '2.6': 0.36; 'accuracy': 0.36; 'functions.': 0.36; 'vice': 0.36; 'url:listinfo': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'should': 0.36; 'detail': 0.37; 'half': 0.37; 'received:169': 0.37; 'wrong': 0.37; 'two': 0.37; 'list': 0.37; 'clear': 0.37; 'implement': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'space': 0.40; 'url:mail': 0.40; 'how': 0.40; 'easy': 0.60; 'around.': 0.60; 'new': 0.61; 'information,': 0.61; 'back': 0.62; 'name': 0.63; 'design,': 0.64; 'therefore,': 0.64; 'more': 0.64; 'forward': 0.65; 'purchase': 0.65; 'latest': 0.67; 'advantages': 0.68; 'answer.': 0.68; 'subject: & ': 0.68; 'subject': 0.69; 'legal': 0.71; 'sale': 0.75; "'view'": 0.84; '2.7.': 0.84; 'confusing': 0.84; 'designed,': 0.84; 'difference.': 0.84; 'duplication,': 0.84; 'received:169.254.8': 0.84; 'conflicts,': 0.91 X-DKIM: OpenDKIM Filter v2.1.3 sf2.jpmchase.com r6PGC3o3016821 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1374768723; bh=p3rvEOTGywSIDS/YSsGKJihIfbX4c4+7q0Czmc7NrdQ=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:content-transfer-encoding:MIME-Version; b=L8RbPz3DLKCJeGZUz61STH/pXN+KHO8LeDZ3V9XFp+2fFBmNFYqgAq1pcPqkMxOqf 7VhSkYL7ao4GQ83mxV/k7ex49CWF1/PWtKYD4anva9ECevr80ulJQ0x7pbTtF/fEG3 qlLKJL99zbcyQYLx0+4v4V9+XaYfoNLideeMx0lg= X-AuditID: a959dca9-b7f588e000002568-92-51f14e51b933 From: "Prasad, Ramit" To: "python-list@python.org" Subject: RE: Python 3: dict & dict.keys() Thread-Topic: Python 3: dict & dict.keys() Thread-Index: AQHOiJKOfYycRz3X90uM6iWVTW41zZl0ahEAgAAYd4D//8Wi4IAAeYmAgADIZXA= Date: Thu, 25 Jul 2013 16:11:47 +0000 References: <51EF2AD8.3080105@stoneleaf.us> <51F01D9E.2030903@stoneleaf.us> <5B80DD153D7D744689F57F4FB69AF474185C131B@SCACMX008.exchad.jpmchase.net> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.79.47] Content-Type: text/plain; charset="us-ascii" content-transfer-encoding: quoted-printable MIME-Version: 1.0 X-DLP-FWD: Yes X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAKsWRmVeSWpSXmKPExsUye4sJr26g38dAg86ZhhZHWq+xOjB6vJj/ hi2AMaqB0SYxLy+/JLEkVSEltTjZVsklszg5JzEzN7VIQVfBqyA3vyg9MU8vOT9XSSEzxVbJ REmhICcxOTU3Na/EVimxoCA1L0XJjksBA9gAlWXmKaTmJeenZOal2yp5BvvrWliYWuoaKtmF ZGQWK6TmJmbmKCRsZM/oanjPVvBRrOLQy2bGBsY5Ql2MnBwSAiYSq5vnsUHYYhIX7q0Hsrk4 hASOMErcXTKXHcI5yCix+MVuZpAqIYFNjBLrF0mA2GwChhLHzz5hB7FFBEwlXq/czQpiCwto SnS9/s0GEdeS2L3tBWMXIweQ7SexabMDSJhFQFVi6qb9LCA2r0CIxM0LT1kgdk1gknh26QDY HE6gOZfaPzCC2IxA130/tYYJxGYWEJe49WQ+E8TVAhJL9pxnhrBFJV4+/scKYctLvJjykg2i Xkdiwe5PULa2xLKFr5khFgtKnJz5hAXkNiEBNYl9621BTAkBPontbdUTGCVmIVk2C8mgWUgG zUIyaAEjyypGyeLc9CxTveKyIr3SYr2sgtzkjMTiVL281JJNjMCEsjLyzsodjP8abQ8xCnAw KvHwKjh9DBRiTSwrrsw9xCjBwawkwssedCRQiDclsbIqtSg/vqg0J7X4EGMVMNAmMkuJJucD k11eSbyhsZmFgampoYGFoZEJVYSVxHnd1j4LFBJIB6bU7NTUgtQimOVMHJxSDYzTQ3dJGTpF L99xdLqyx5LTv+bETvFeH/WsQ+fU8ZKnm8s7j7zyYrl/J6ps5p4CR2PZFUXypf6XGZ7IrZzv Y1/xI+nmr9DwTUvaDm4LMWnb9Fef81SdhZiJ0NU5579F9Ac+4+o/bPpl7uT7i6+0yOmssDva bDVpuucsr8XXv6tOlvgevqXv5NIMJZbijERDLeai4kQAQzVn4YMDAAA= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 72 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374768726 news.xs4all.nl 15966 [2001:888:2000:d::a6]:40178 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51239 Terry Reedy wrote: > > On 7/24/2013 4:34 PM, Prasad, Ramit wrote: > > > I am still not clear on the advantage of views vs. iterators. > > A1: Views are iterables that can be iterated more than once. Therefore, > they can be passed to a function that re-iterates its inputs, or to > multiple functions. They support 'x in view' as efficiently as possible. > Think about how you would write the non-view equivalent of '(0,None) in > somedict.views())'. When set-like, views support some set operations. > For .keys, which are always set-like, these operations are easy to > implement as dicts are based on a hashed array of keys. Hmm, that is a change that makes some sense to me. Does the view get updated when dictionary changes or is a new view needed? I assume the latter. > > Q2: What is the advantage of views vs. lists? > > A2: They do not take up space that is not needed. They can be converted > to lists, to get all the features of lists, but not vice versa. > > > What makes d.viewkeys() better than d.iterkeys()? Why did they decide > > not to rename d.iterkeys() to d.keys() and instead use d.viewkeys()? > > This is historically the wrong way to phrase the question. The 2.7 > .viewxyz methods were *not* used to make the 3.x .xyz methods. It was > the other way around. 3.0 came out with view methods replacing both list > and iter methods just after 2.6, after a couple of years of design, and > a year and a half before 2.7. The view methods were backported from 3.1 > to 2.7, with 'view' added to the name to avoid name conflicts, to make > it easier to write code that would either run on both 2.7 and 3.x or be > converted with 2to3. > > A better question is: 'When 3.0 was designed, why were views invented > for the .xyz methods rather than just renaming the .iterxyz methods. The > advantages given above are the answer. View methods replace both list > and iterator methods and are more flexible than either and directly or > indirectly have all the advantages of both. > > My question is why some people are fussing so much because Python > developers gave them one thing that is better than either of the two > things it replaces? I personally am not "fussing" as existing functionality was preserved (and improved). I just was not clear on the difference. Thanks for all the detail and context. > > The mis-phrased question above illustrates why people new to Python > should use the latest 3.x and ignore 2.x unless they must use 2.x > libraries. 2.7 has all the old stuff, for back compatibility, and as > much of the new stuff in 3.1 as seemed sensible, for forward > compatibility. Thus it has lots of confusing duplication, and in this > case, triplication I work with 2.6 so no choice there... :) > > -- > Terry Jan Reedy > > -- > http://mail.python.org/mailman/listinfo/python-list This email is confidential and subject to important disclaimers and conditio= ns including on offers for the purchase or sale of securities, accuracy and= completeness of information, viruses, confidentiality, legal privilege, and= legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclo= sures/email.