A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

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>&lt;python-dev-request@python.org&gt;</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 &lt;python-dev-request@python.org&gt;<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>       &nbsppython-dev@python.org<br><br>To subscribe or unsubscribe via the World Wide Web, visit<br>       &nbsphttp://mail.python.org/mailman/listinfo/python-dev<br>or, via email, send a message with subject or body 'help' to<br>       &nbsppython-dev-request@python.org<br><br>You can reach the person managing the list at<br>       &nbsppython-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 &lt;jflatow@northwestern.edu&gt;<br>wrote:<br>&gt; PEP 207 (http://www.python.org/dev/peps/pep-0207/) states in the fourth<br>&gt; clause of the proposed resolutions to concerns:<br>&gt;<br>&gt; "The reflexivity rules *are* assumed by Python.  Thus, the<br>interpreter may<br>&gt; swap y&gt;x with x&lt;y, y&gt;=x with x&lt;=y, and may swap the arguments<br>of x==y and<br>&gt; x!=y."<br>&gt;<br>&gt; However, if this is the case, why does Python allow the definition of both<br>&gt; pairs of __le__, __ge__ and __lt__, __gt__ for a single class, since users<br>&gt; have no guarantee over which will be called? Currently, if I do not want x<br>&gt;&gt;= y to mean the same thing as y &lt;= x (and believe it or not I<br>believe I<br>&gt; 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>&gt;
 there is no reliable way of doing this.<br><br>Does it help if I tell you that for "x &lt;binop&gt; 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>&gt; However, if the decision is to not allow users to do this at all using<br>&gt; operators (and force them to create specially named methods), what is the<br>&gt; 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>&lt;binop&gt; 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>&gt; It seems very confusing to me (and<br>&gt; indeed I was at first very confused what was going on), to tempt users to<br>be<br>&gt; able to define both but give no promise that if they do, the
 appropriate<br>one<br>&gt; 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>&lt;aleaxit@gmail.com&gt; ha scritto:<br><br>&gt; On Fri, Jun 6, 2008 at 11:01 AM, Guido van Rossum &lt;guido@python.org&gt;<br>wrote:<br>&gt;&gt; On Thu, Jun 5, 2008 at 8:45 PM, Raymond Hettinger<br>&lt;python@rcn.com&gt; wrote:<br>&gt;&gt;&gt; Does anyone actually need an int lookalike with binary methods but<br>&gt;&gt;&gt; cannot just inherit from int?<br>&gt;&gt;<br>&gt;&gt; Does anyone actually need an int lookalike with operations like +, -<br>&gt;&gt; etc. but cannot just inherit from int? If the answer is yes, is there<br>&gt;&gt; a compelling reason why they wouldn't want to support binary<br>methods<br>&gt;&gt; as well?<br>&gt;<br>&gt; Yes, there's a use case for
 implementing long integers as arrays of<br>&gt; decimal digits -- addition is roughly as efficient as for binary<br>&gt; integers (x86 chips still have instructions to help with that), and<br>&gt; emitting as decimal digits is MUCH more efficient of course -- so if<br>&gt; I/O in decimal form is the most common operation, with a little<br>&gt; arithmetic (particularly sums), you could gain performance; binary<br>&gt; operations, however, would be as inefficient as decimal form<br>&gt; conversion is for ordinary binary ints, and not needed for the typical<br>&gt; applications that would use these "decimal coded integers"<br>&gt; (accounting), so why not save the implementer of such an extension<br>&gt; from having to write that unneeded and slow extra code?<br>&gt;<br>&gt;<br>&gt; 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 &amp; 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 &lt;&lt; other"""<br>        return long(self) &lt;&lt; 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" &lt;aleaxit@gmail.com&gt;<br>To: "Guido van Rossum" &lt;guido@python.org&gt;<br>Cc: "Raymond Hettinger" &lt;python@rcn.com&gt;;<br>&lt;python-dev@python.org&gt;<br>Sent: Friday, June 06, 2008 11:40 AM<br>Subject: Re: [Python-Dev] Mini-Pep: Simplifying the Integral ABC<br><br><br>&gt; On Fri, Jun 6, 2008 at 11:01 AM, Guido van Rossum &lt;guido@python.org&gt;<br>wrote:<br>&gt;&gt; On Thu, Jun 5, 2008 at 8:45 PM, Raymond Hettinger<br>&lt;python@rcn.com&gt; wrote:<br>&gt;&gt;&gt; Does anyone actually need an int lookalike with binary methods but<br>&gt;&gt;&gt; cannot just inherit from int?<br>&gt;&gt;<br>&gt;&gt; Does
 anyone actually need an int lookalike with operations like +, -<br>&gt;&gt; etc. but cannot just inherit from int? If the answer is yes, is there<br>&gt;&gt; a compelling reason why they wouldn't want to support binary<br>methods<br>&gt;&gt; as well?<br>&gt;<br>&gt; Yes, there's a use case for implementing long integers as arrays of<br>&gt; decimal digits -- addition is roughly as efficient as for binary<br>&gt; integers (x86 chips still have instructions to help with that), and<br>&gt; emitting as decimal digits is MUCH more efficient of course -- so if<br>&gt; I/O in decimal form is the most common operation, with a little<br>&gt; arithmetic (particularly sums), you could gain performance; binary<br>&gt; operations, however, would be as inefficient as decimal form<br>&gt; conversion is for ordinary binary ints, and not needed for the typical<br>&gt; applications that would use these "decimal coded integers"<br>&gt; (accounting), so why not save the
 implementer of such an extension<br>&gt; from having to write that unneeded and slow extra code?<br>&gt;<br>&gt;<br>&gt; Alex</pre><pre>On Jun 6, 2008, at 3:24 PM, Guido van Rossum wrote:<br><br>&gt; On Fri, Jun 6, 2008 at 1:10 PM, Jared Flatow  <br>&gt; &lt;jflatow@northwestern.edu&gt; wrote:<br>&gt;&gt; PEP 207 (http://www.python.org/dev/peps/pep-0207/) states in the  <br>&gt;&gt; fourth<br>&gt;&gt; clause of the proposed resolutions to concerns:<br>&gt;&gt;<br>&gt;&gt; "The reflexivity rules *are* assumed by Python.  Thus, the  <br>&gt;&gt; interpreter may<br>&gt;&gt; swap y&gt;x with x&lt;y, y&gt;=x with x&lt;=y, and may swap the<br>arguments of  <br>&gt;&gt; x==y and<br>&gt;&gt; x!=y."<br>&gt;&gt;<br>&gt;&gt; However, if this is the case, why does Python allow the definition  <br>&gt;&gt; of both<br>&gt;&gt; pairs of __le__, __ge__ and __lt__, __gt__ for a single class,  <br>&gt;&gt; since users<br>&gt;&gt; have no guarantee over which will be
 called? Currently, if I do not  <br>&gt;&gt; want x<br>&gt;&gt;&gt; = y to mean the same thing as y &lt;= x (and believe it or not I  <br>&gt;&gt;&gt; believe I<br>&gt;&gt; have a good use case for doing this),<br>&gt;<br>&gt; I find it hard to believe that your users will be happy with that  <br>&gt; 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>&gt;&gt; there is no reliable way of doing this.<br>&gt;<br>&gt; Does it help if I tell you that for "x &lt;binop&gt; y" we<br>always try<br>&gt; x.__binop__(y) before trying y.__reverse_binop__(x), *except* in the<br>&gt; 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>&gt;&gt; However, if the decision is to not allow users to do this at all  <br>&gt;&gt; using<br>&gt;&gt; operators (and force them to create specially named methods), what  <br>&gt;&gt; is the<br>&gt;&gt; point of allowing the definition of both?<br>&gt;<br>&gt; The same reason we allow (require) you to define __add__ and __radd_.<br>&gt; It is quite possible that for any particular binary operation "x<br>&gt; &lt;binop&gt; y", the class of x doesn't know how to implement<br>it, and then<br>&gt; the class of y is tried with the reversed operation.<br>&gt;<br>&gt;&gt; It seems very confusing to me (and<br>&gt;&gt; indeed I was at first very confused what was going on), to tempt  <br>&gt;&gt; users to be<br>&gt;&gt; able to define both but give no promise that if they do, the  <br>&gt;&gt; appropriate one<br>&gt;&gt; will be called. Does anyone have a good explanation for
 this?<br>&gt;<br>&gt; 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 &lt;python@rcn.com&gt; wrote:<br>&gt; New idea!  I missed an obvious solution. Let the binary methods in<br>Integral<br>&gt; be mixins instead of abstract methods.  That minimizes the burden on the<br>&gt; class implementer while providing maximum support for clients.<br>&gt;<br>&gt; class Integral(Rational):<br>&gt;   ...<br>&gt;   def __lshift__(self, other):<br>&gt;       """self &lt;&lt; other"""<br>&gt;       return long(self) &lt;&lt; long(other)<br>&gt;   def __xor__(self, other):<br>&gt;       """self ^ other"""<br>&gt;       return long(self) ^ long(other)<br>&gt;<br>&gt; I worried a bit about changing type, but this kind of thing is already<br>baked<br>&gt; into
 numbers.py:<br>&gt;<br>&gt;   @property<br>&gt;   def imag(self):<br>&gt;       """Real numbers have no imaginary<br>component."""<br>&gt;       return 0<br>&gt;<br>&gt;   @property<br>&gt;   def denominator(self):<br>&gt;       """Integers have a denominator of<br>1."""<br>&gt;       return 1<br>&gt;<br>&gt; Raymond<br>&gt;<br>&gt;<br>&gt; ----- Original Message ----- From: "Alex Martelli"<br>&lt;aleaxit@gmail.com&gt;<br>&gt; To: "Guido van Rossum" &lt;guido@python.org&gt;<br>&gt; Cc: "Raymond Hettinger" &lt;python@rcn.com&gt;;<br>&lt;python-dev@python.org&gt;<br>&gt; Sent: Friday, June 06, 2008 11:40 AM<br>&gt; Subject: Re: [Python-Dev] Mini-Pep: Simplifying the Integral ABC<br>&gt;<br>&gt;<br>&gt;&gt; On Fri, Jun 6, 2008 at 11:01 AM, Guido van Rossum<br>&lt;guido@python.org&gt;<br>&gt;&gt; wrote:<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; On Thu, Jun 5, 2008 at 8:45 PM, Raymond Hettinger<br>&lt;python@rcn.com&gt; wrote:<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;
 Does anyone actually need an int lookalike with binary methods<br>but<br>&gt;&gt;&gt;&gt; cannot just inherit from int?<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Does anyone actually need an int lookalike with operations like +,<br>-<br>&gt;&gt;&gt; etc. but cannot just inherit from int? If the answer is yes, is<br>there<br>&gt;&gt;&gt; a compelling reason why they wouldn't want to support binary<br>methods<br>&gt;&gt;&gt; as well?<br>&gt;&gt;<br>&gt;&gt; Yes, there's a use case for implementing long integers as arrays<br>of<br>&gt;&gt; decimal digits -- addition is roughly as efficient as for binary<br>&gt;&gt; integers (x86 chips still have instructions to help with that), and<br>&gt;&gt; emitting as decimal digits is MUCH more efficient of course -- so if<br>&gt;&gt; I/O in decimal form is the most common operation, with a little<br>&gt;&gt; arithmetic (particularly sums), you could gain performance; binary<br>&gt;&gt; operations, however, would be as
 inefficient as decimal form<br>&gt;&gt; conversion is for ordinary binary ints, and not needed for the typical<br>&gt;&gt; applications that would use these "decimal coded integers"<br>&gt;&gt; (accounting), so why not save the implementer of such an extension<br>&gt;&gt; from having to write that unneeded and slow extra code?<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; Alex<br>&gt;<br>&gt;<br><br><br><br>-- <br>--Guido van Rossum (home page: http://www.python.org/~guido/)</pre><pre>From: "Guido van Rossum" &lt;guido@python.org&gt;<br>&gt; 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>&gt; I created an issue 1 week ago (http://bugs.python.org/issue2983)<br>&gt; suggesting the addition
 of the ttk module to lib-tk, and to the new<br>&gt; tkinter package. Is there any chance to this be accepted for Python<br>&gt; 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