<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 17, 2014, at 1:07 PM, Raymond Hettinger <<a href="mailto:raymond.hettinger@gmail.com" class="">raymond.hettinger@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><div class="">On Aug 17, 2014, at 1:41 AM, Nick Coghlan <<a href="mailto:ncoghlan@gmail.com" class="">ncoghlan@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite" class=""><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;" class="">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;" class=""><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;" class="">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;" class=""><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;" class="">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;" class=""><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;" class=""><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;" class="">"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;" class=""><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;" class="">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;" class=""></blockquote><div class=""><br class=""></div><div class="">Zeros would have been great but that should have been done originally.</div><div class="">The time to get API design right is at inception.</div><div class="">Now, you're just breaking code and invalidating any published examples.</div><br class=""><blockquote type="cite" class=""><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;" class=""><br class="">Another thought is that the core devs should be very reluctant to deprecate<br class="">anything we don't have to while the 2 to 3 transition is still in progress.<br class="">Every new deprecation of APIs that existed in Python 2.7 just adds another<br class="">obstacle to converting code.  Individually, the differences are trivial.<br class="">Collectively, they present a good reason to never migrate code to Python 3.<br class=""></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;" class=""><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;" class="">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;" class=""><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;" class="">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;" class=""></blockquote><br class=""></div><div class="">However, bytearray(n) is the same in both Python 2 and Python 3.</div><div class="">Changing it in Python 3 increases the gulf between the two.</div><div class=""><br class=""></div><div class="">The further we let Python 3 diverge from Python 2, the less likely that</div><div class="">people will convert their code and the harder you make it to write code</div><div class="">that runs under both.</div><div class=""><br class=""></div><div class="">FWIW, I've been teaching Python full time for three years.  I cover the</div><div class="">use of bytearray(n) in my classes and not a single person out of 3000+</div><div class="">engineers have had a problem with it.   I seriously question the PEP's</div><div class="">assertion that there is a real problem to be solved (i.e. that people</div><div class="">are baffled by bytearray(bufsiz)) and that the problem is sufficiently</div><div class="">painful to warrant the headaches that go along with API changes.</div><div class=""><br class=""></div><div class="">The other proposal to add bytearray.byte(3) should probably be named</div><div class="">bytearray.from_byte(3) for clarity.  That said, I question whether there is</div><div class="">actually a use case for this.   I have never seen seen code that has a</div><div class="">need to create a byte array of length one from a single integer.</div><div class="">For the most part, the API will be easiest to learn if it matches what</div><div class="">we do for lists and for array.array.</div><div class=""><br class=""></div><div class="">Sorry Nick, but I think you're making the API worse instead of better.</div><div class="">This API isn't perfect but it isn't flat-out broken either.   There is some</div><div class="">unfortunate asymmetry between bytes() and bytearray() in Python 2,</div><div class="">but that ship has sailed.  The current API for Python 3 is pretty good</div><div class="">(though there is still a tension between wanting to be like lists and like</div><div class="">strings both at the same time).</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Raymond</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">P.S.  The most important problem in the Python world now is getting</div><div class="">Python 2 users to adopt Python 3.  The core devs need to develop</div><div class="">a strong distaste for anything that makes that problem harder.</div><div class=""><br class=""></div></div></div></blockquote><br class=""></div><div>For the record I’ve had all of the problems that Nick states and I’m</div><div>+1 on this change.</div><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: 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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: 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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">---</div><div class="">Donald Stufft</div><div class="">PGP: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA</div></div></div>
</div>
<br class=""></body></html>