<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Aug 17, 2014, at 1:41 AM, Nick Coghlan <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">If I see "bytearray(10)" there is nothing there that suggests "this</span><br style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">creates an array of length 10 and initialises it to zero" to me. I'd</span><br style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">be more inclined to guess it would be equivalent to "bytearray([10])".</span><br style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">"bytearray.zeros(10)", on the other hand, is relatively clear,</span><br style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">independently of user expectations.</span><br style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></blockquote><div><br></div><div>Zeros would have been great but that should have been done originally.</div><div>The time to get API design right is at inception.</div><div>Now, you're just breaking code and invalidating any published examples.</div><br><blockquote type="cite"><blockquote type="cite" style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>Another thought is that the core devs should be very reluctant to deprecate<br>anything we don't have to while the 2 to 3 transition is still in progress.<br>Every new deprecation of APIs that existed in Python 2.7 just adds another<br>obstacle to converting code.  Individually, the differences are trivial.<br>Collectively, they present a good reason to never migrate code to Python 3.<br></blockquote><br style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">This is actually one of the inconsistencies between the Python 2 and 3</span><br style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">binary APIs:</span><br style="font-family: ArialMT; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></blockquote><br></div><div>However, bytearray(n) is the same in both Python 2 and Python 3.</div><div>Changing it in Python 3 increases the gulf between the two.</div><div><br></div><div>The further we let Python 3 diverge from Python 2, the less likely that</div><div>people will convert their code and the harder you make it to write code</div><div>that runs under both.</div><div><br></div><div>FWIW, I've been teaching Python full time for three years.  I cover the</div><div>use of bytearray(n) in my classes and not a single person out of 3000+</div><div>engineers have had a problem with it.   I seriously question the PEP's</div><div>assertion that there is a real problem to be solved (i.e. that people</div><div>are baffled by bytearray(bufsiz)) and that the problem is sufficiently</div><div>painful to warrant the headaches that go along with API changes.</div><div><br></div><div>The other proposal to add bytearray.byte(3) should probably be named</div><div>bytearray.from_byte(3) for clarity.  That said, I question whether there is</div><div>actually a use case for this.   I have never seen seen code that has a</div><div>need to create a byte array of length one from a single integer.</div><div>For the most part, the API will be easiest to learn if it matches what</div><div>we do for lists and for array.array.</div><div><br></div><div>Sorry Nick, but I think you're making the API worse instead of better.</div><div>This API isn't perfect but it isn't flat-out broken either.   There is some</div><div>unfortunate asymmetry between bytes() and bytearray() in Python 2,</div><div>but that ship has sailed.  The current API for Python 3 is pretty good</div><div>(though there is still a tension between wanting to be like lists and like</div><div>strings both at the same time).</div><div><br></div><div><br></div><div>Raymond</div><div><br></div><div><br></div><div>P.S.  The most important problem in the Python world now is getting</div><div>Python 2 users to adopt Python 3.  The core devs need to develop</div><div>a strong distaste for anything that makes that problem harder.</div><div><br></div><div><br></div><div><br></div><div><br></div><br></body></html>