Showing content from http://mail.python.org/pipermail/python-dev/attachments/20080606/ffcea19a/attachment-0001.htm below:
<table cellspacing='0' cellpadding='0' border='0' background='none' style='font-family:arial;font-size:10pt;color:rgb(51, 51, 51);background-color:rgb(255, 255, 255);width:100%;'><tr><td valign='top' style='font: inherit;'>Hi All,<br>I'm a new developer with Python. I have a solid knowledge of both Python and C. Are there any tasks that would be suitable for a beginner to the Python codebase? I haven't been able to find a list of such tasks on python.org or bugs.python.org.<br>Thanks,<br>James Thomas<br><br>--- On <b>Fri, 6/6/08, python-dev-request@python.org <i><python-dev-request@python.org></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">From: python-dev-request@python.org <python-dev-request@python.org><br>Subject: Python-Dev Digest, Vol 59, Issue 24<br>To: python-dev@python.org<br>Date: Friday, June 6, 2008, 2:30 PM<br><br><pre>Send Python-Dev mailing list submissions
to<br>  python-dev@python.org<br><br>To subscribe or unsubscribe via the World Wide Web, visit<br>  http://mail.python.org/mailman/listinfo/python-dev<br>or, via email, send a message with subject or body 'help' to<br>  python-dev-request@python.org<br><br>You can reach the person managing the list at<br>  python-dev-owner@python.org<br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of Python-Dev digest..."</pre><pre>Today's Topics:<br><br> 1. Re: Assumed reflexivity of rich comparison operators<br> (Guido van Rossum)<br> 2. Re: Mini-Pep: Simplifying the Integral ABC (Cesare Di Mauro)<br> 3. Re: Mini-Pep: Simplifying the Integral ABC (Raymond Hettinger)<br> 4. Re: Assumed reflexivity of rich comparison operators<br> (Jared Flatow)<br> 5. Re: Mini-Pep: Simplifying the Integral ABC (Guido van Rossum)<br> 6. Re: Mini-Pep: Simplifying the Integral ABC (Raymond Hettinger)<br> 7. Re: Modules
for 2.6 inclusion (Martin v. L?wis)</pre><pre>On Fri, Jun 6, 2008 at 1:10 PM, Jared Flatow <jflatow@northwestern.edu><br>wrote:<br>> PEP 207 (http://www.python.org/dev/peps/pep-0207/) states in the fourth<br>> clause of the proposed resolutions to concerns:<br>><br>> "The reflexivity rules *are* assumed by Python. Thus, the<br>interpreter may<br>> swap y>x with x<y, y>=x with x<=y, and may swap the arguments<br>of x==y and<br>> x!=y."<br>><br>> However, if this is the case, why does Python allow the definition of both<br>> pairs of __le__, __ge__ and __lt__, __gt__ for a single class, since users<br>> have no guarantee over which will be called? Currently, if I do not want x<br>>>= y to mean the same thing as y <= x (and believe it or not I<br>believe I<br>> have a good use case for doing this),<br><br>I find it hard to believe that your users will be happy with that though. :-)<br><br>>
there is no reliable way of doing this.<br><br>Does it help if I tell you that for "x <binop> y" we always try<br>x.__binop__(y) before trying y.__reverse_binop__(x), *except* in the<br>case where y is an instance of a subclass of the class of x?<br><br>> However, if the decision is to not allow users to do this at all using<br>> operators (and force them to create specially named methods), what is the<br>> point of allowing the definition of both?<br><br>The same reason we allow (require) you to define __add__ and __radd_.<br>It is quite possible that for any particular binary operation "x<br><binop> y", the class of x doesn't know how to implement it, and<br>then<br>the class of y is tried with the reversed operation.<br><br>> It seems very confusing to me (and<br>> indeed I was at first very confused what was going on), to tempt users to<br>be<br>> able to define both but give no promise that if they do, the
appropriate<br>one<br>> will be called. Does anyone have a good explanation for this?<br><br>I have explained it as well as I can.<br><br>-- <br>--Guido van Rossum (home page: http://www.python.org/~guido/)</pre><pre>In data 06 giugno 2008 alle ore 20:40:01, Alex Martelli<br><aleaxit@gmail.com> ha scritto:<br><br>> On Fri, Jun 6, 2008 at 11:01 AM, Guido van Rossum <guido@python.org><br>wrote:<br>>> On Thu, Jun 5, 2008 at 8:45 PM, Raymond Hettinger<br><python@rcn.com> wrote:<br>>>> Does anyone actually need an int lookalike with binary methods but<br>>>> cannot just inherit from int?<br>>><br>>> Does anyone actually need an int lookalike with operations like +, -<br>>> etc. but cannot just inherit from int? If the answer is yes, is there<br>>> a compelling reason why they wouldn't want to support binary<br>methods<br>>> as well?<br>><br>> Yes, there's a use case for
implementing long integers as arrays of<br>> decimal digits -- addition is roughly as efficient as for binary<br>> integers (x86 chips still have instructions to help with that), and<br>> emitting as decimal digits is MUCH more efficient of course -- so if<br>> I/O in decimal form is the most common operation, with a little<br>> arithmetic (particularly sums), you could gain performance; binary<br>> operations, however, would be as inefficient as decimal form<br>> conversion is for ordinary binary ints, and not needed for the typical<br>> applications that would use these "decimal coded integers"<br>> (accounting), so why not save the implementer of such an extension<br>> from having to write that unneeded and slow extra code?<br>><br>><br>> Alex<br><br>I don't know if you are talking about BCD numbers, but they are quite<br>inefficient and slow in x86 architecture.<br>There are instructions only to add and
subtract packed BCD numbers which uses<br>just two decimal digits (packed in two nibbles into a single byte).<br>For unpacked BCDs, there are instructions to add, subtract, multiply and divide<br>numbers, but which uses only one digit at the time.<br><br>So using packed BCDs to store 8 decimal digits in 32 bits, for example,<br>requires 4 instructions to make addictions or subractions, plus the required<br>shift & mask instructions to put every couple digits into the AL register<br>to execute BCD operations.<br>Unpacked BCDs need double of them.<br><br>Also, these instructions still use microcode to execute on modern processors,<br>slowing down the execution pipeline (most of the simpler instructions do not<br>require microcode, and execute "directly").<br><br>Last but not least, on x86-64 architecture BCD instructions were completely<br>removed from the ISA; opcodes are assigned to new instructions. Obviously,<br>binary operations can be performed
twice faster thanks to the 64 bit registers<br>and ALUs.<br><br>The only practical advantage on using BCD numbers is the conversion-to-string<br>operation, which can be done faster than binary numbers.<br><br>Binary addition, subtraction, multiplication and division are greatly faster<br>than BCD ones, and should be the preferred way to do integer math.<br><br>Cesare</pre><pre>New idea! I missed an obvious solution. Let the binary methods in Integral be<br>mixins instead of abstract methods. That minimizes <br>the burden on the class implementer while providing maximum support for<br>clients.<br><br>class Integral(Rational):<br> ...<br> def __lshift__(self, other):<br> """self << other"""<br> return long(self) << long(other)<br> def __xor__(self, other):<br> """self ^ other"""<br> return long(self) ^ long(other)<br><br>I worried a bit about changing type, but this kind of thing is already baked<br>into
numbers.py:<br><br> @property<br> def imag(self):<br> """Real numbers have no imaginary<br>component."""<br> return 0<br><br> @property<br> def denominator(self):<br> """Integers have a denominator of 1."""<br> return 1<br><br>Raymond<br><br><br>----- Original Message ----- <br>From: "Alex Martelli" <aleaxit@gmail.com><br>To: "Guido van Rossum" <guido@python.org><br>Cc: "Raymond Hettinger" <python@rcn.com>;<br><python-dev@python.org><br>Sent: Friday, June 06, 2008 11:40 AM<br>Subject: Re: [Python-Dev] Mini-Pep: Simplifying the Integral ABC<br><br><br>> On Fri, Jun 6, 2008 at 11:01 AM, Guido van Rossum <guido@python.org><br>wrote:<br>>> On Thu, Jun 5, 2008 at 8:45 PM, Raymond Hettinger<br><python@rcn.com> wrote:<br>>>> Does anyone actually need an int lookalike with binary methods but<br>>>> cannot just inherit from int?<br>>><br>>> Does
anyone actually need an int lookalike with operations like +, -<br>>> etc. but cannot just inherit from int? If the answer is yes, is there<br>>> a compelling reason why they wouldn't want to support binary<br>methods<br>>> as well?<br>><br>> Yes, there's a use case for implementing long integers as arrays of<br>> decimal digits -- addition is roughly as efficient as for binary<br>> integers (x86 chips still have instructions to help with that), and<br>> emitting as decimal digits is MUCH more efficient of course -- so if<br>> I/O in decimal form is the most common operation, with a little<br>> arithmetic (particularly sums), you could gain performance; binary<br>> operations, however, would be as inefficient as decimal form<br>> conversion is for ordinary binary ints, and not needed for the typical<br>> applications that would use these "decimal coded integers"<br>> (accounting), so why not save the
implementer of such an extension<br>> from having to write that unneeded and slow extra code?<br>><br>><br>> Alex</pre><pre>On Jun 6, 2008, at 3:24 PM, Guido van Rossum wrote:<br><br>> On Fri, Jun 6, 2008 at 1:10 PM, Jared Flatow <br>> <jflatow@northwestern.edu> wrote:<br>>> PEP 207 (http://www.python.org/dev/peps/pep-0207/) states in the <br>>> fourth<br>>> clause of the proposed resolutions to concerns:<br>>><br>>> "The reflexivity rules *are* assumed by Python. Thus, the <br>>> interpreter may<br>>> swap y>x with x<y, y>=x with x<=y, and may swap the<br>arguments of <br>>> x==y and<br>>> x!=y."<br>>><br>>> However, if this is the case, why does Python allow the definition <br>>> of both<br>>> pairs of __le__, __ge__ and __lt__, __gt__ for a single class, <br>>> since users<br>>> have no guarantee over which will be
called? Currently, if I do not <br>>> want x<br>>>> = y to mean the same thing as y <= x (and believe it or not I <br>>>> believe I<br>>> have a good use case for doing this),<br>><br>> I find it hard to believe that your users will be happy with that <br>> though. :-)<br><br>In this case, I am my users and I would be very happy with it (but I <br>won't try to justify it :).<br><br>>> there is no reliable way of doing this.<br>><br>> Does it help if I tell you that for "x <binop> y" we<br>always try<br>> x.__binop__(y) before trying y.__reverse_binop__(x), *except* in the<br>> case where y is an instance of a subclass of the class of x?<br><br>Yes, actually that explains quite a bit, and now I see that is the <br>case I am dealing with. y is an instance of a subclass of x, but the <br>class of x is the one that defines both the binops. I suppose it is <br>too much to ask to only
call the __reverse_binop__ if the subclass <br>overrides it.<br><br>>> However, if the decision is to not allow users to do this at all <br>>> using<br>>> operators (and force them to create specially named methods), what <br>>> is the<br>>> point of allowing the definition of both?<br>><br>> The same reason we allow (require) you to define __add__ and __radd_.<br>> It is quite possible that for any particular binary operation "x<br>> <binop> y", the class of x doesn't know how to implement<br>it, and then<br>> the class of y is tried with the reversed operation.<br>><br>>> It seems very confusing to me (and<br>>> indeed I was at first very confused what was going on), to tempt <br>>> users to be<br>>> able to define both but give no promise that if they do, the <br>>> appropriate one<br>>> will be called. Does anyone have a good explanation for
this?<br>><br>> I have explained it as well as I can.<br><br>Thanks very much, at least that is enough information to work around <br>reliably.<br><br>jared</pre><pre>Make that int() instead of long() and I'm okay with it.<br><br>On Fri, Jun 6, 2008 at 1:33 PM, Raymond Hettinger <python@rcn.com> wrote:<br>> New idea! I missed an obvious solution. Let the binary methods in<br>Integral<br>> be mixins instead of abstract methods. That minimizes the burden on the<br>> class implementer while providing maximum support for clients.<br>><br>> class Integral(Rational):<br>> ...<br>> def __lshift__(self, other):<br>> """self << other"""<br>> return long(self) << long(other)<br>> def __xor__(self, other):<br>> """self ^ other"""<br>> return long(self) ^ long(other)<br>><br>> I worried a bit about changing type, but this kind of thing is already<br>baked<br>> into
numbers.py:<br>><br>> @property<br>> def imag(self):<br>> """Real numbers have no imaginary<br>component."""<br>> return 0<br>><br>> @property<br>> def denominator(self):<br>> """Integers have a denominator of<br>1."""<br>> return 1<br>><br>> Raymond<br>><br>><br>> ----- Original Message ----- From: "Alex Martelli"<br><aleaxit@gmail.com><br>> To: "Guido van Rossum" <guido@python.org><br>> Cc: "Raymond Hettinger" <python@rcn.com>;<br><python-dev@python.org><br>> Sent: Friday, June 06, 2008 11:40 AM<br>> Subject: Re: [Python-Dev] Mini-Pep: Simplifying the Integral ABC<br>><br>><br>>> On Fri, Jun 6, 2008 at 11:01 AM, Guido van Rossum<br><guido@python.org><br>>> wrote:<br>>>><br>>>> On Thu, Jun 5, 2008 at 8:45 PM, Raymond Hettinger<br><python@rcn.com> wrote:<br>>>>><br>>>>>
Does anyone actually need an int lookalike with binary methods<br>but<br>>>>> cannot just inherit from int?<br>>>><br>>>> Does anyone actually need an int lookalike with operations like +,<br>-<br>>>> etc. but cannot just inherit from int? If the answer is yes, is<br>there<br>>>> a compelling reason why they wouldn't want to support binary<br>methods<br>>>> as well?<br>>><br>>> Yes, there's a use case for implementing long integers as arrays<br>of<br>>> decimal digits -- addition is roughly as efficient as for binary<br>>> integers (x86 chips still have instructions to help with that), and<br>>> emitting as decimal digits is MUCH more efficient of course -- so if<br>>> I/O in decimal form is the most common operation, with a little<br>>> arithmetic (particularly sums), you could gain performance; binary<br>>> operations, however, would be as
inefficient as decimal form<br>>> conversion is for ordinary binary ints, and not needed for the typical<br>>> applications that would use these "decimal coded integers"<br>>> (accounting), so why not save the implementer of such an extension<br>>> from having to write that unneeded and slow extra code?<br>>><br>>><br>>> Alex<br>><br>><br><br><br><br>-- <br>--Guido van Rossum (home page: http://www.python.org/~guido/)</pre><pre>From: "Guido van Rossum" <guido@python.org><br>> Make that int() instead of long() and I'm okay with it.<br><br>Does anyone know why Integral says that __long__ is a required abstract method,<br>but not __int__?<br><br>Likewise, why is index() defined as long(self) instead of int(self)?<br><br>There may be some design nuance that I'm not seeing.<br><br><br>Raymond</pre><pre>> I created an issue 1 week ago (http://bugs.python.org/issue2983)<br>> suggesting the addition
of the ttk module to lib-tk, and to the new<br>> tkinter package. Is there any chance to this be accepted for Python<br>> 2.6 ?<br><br>Is it complete? In principle, it's for the mentor to decide (who<br>would need to decide before the first beta, of course - afterwards<br>it's for the release manager to decide).<br><br>Regards,<br>Martin</pre><pre>_______________________________________________<br>Python-Dev mailing list<br>Python-Dev@python.org<br>http://mail.python.org/mailman/listinfo/python-dev</pre></blockquote></td></tr></table><br>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4