Re: [Python-Dev] Requesting that a class be a new-style class

2005-02-19 Thread Michael Walter
But... only as an additional option, not as a replacement, right?

Michael


On Sat, 19 Feb 2005 03:01:14 -0500, Raymond Hettinger [EMAIL PROTECTED] wrote:
   This is something I've typed way too many times:
  
   Py class C():
 File stdin, line 1
   class C():
   ^
   SyntaxError: invalid syntax
  
   It's the asymmetry with functions that gets to me - defining a
   function with no arguments still requires parentheses in the
   definition statement, but defining a class with no bases requires the
   parentheses to be omitted.
 
  Seconded.  It's always irked me enough that it's the only ``apology''
  for Python syntax you'll see in the Nutshell -- top of p. 71, The
  syntax of the class statement has a small, tricky difference from that
  of the def statement etc.
 
 +1  For me, this would come-up when experimenting with mixins.  Adding and 
 removing a mixin usually entailed a corresponding
 change to the parentheses.
 
 
 Raymond
 
 ___
 Python-Dev mailing list
 Python-Dev@python.org
 http://mail.python.org/mailman/listinfo/python-dev
 Unsubscribe: 
 http://mail.python.org/mailman/options/python-dev/michael.walter%40gmail.com

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Re: Prospective Peephole Transformation

2005-02-19 Thread Fredrik Lundh
Tim Peters wrote:

 [Fredrik Lundh]
 wouldn't be the first time...

 How soon we forget wink.

oh, that was in the dark ages of Python 1.4.  I've rebooted myself many times 
since
then...

 Fredrik introduced a pile of optimizations special-casing the snot out
 of small integers into ceval.c a long time ago

iirc, you claimed that after a couple of major optimizations had been added, 
there's
no single optimization left that can speed up pystone by more than X%, so I 
came
up with an (X+2)% optimization.  you should do that more often ;-)

 As a result, i == j in Python source code, when i and j are little
 ints, is much faster than comparing i and j via any other route in
 Python.

which explains why my in vs. or tests showed good results for integers, but 
not
for strings...

I'd say that this explains why it would still make sense to let the code 
generator change
x in (a, b, c) to x == a or x == b or x == c, as long as a, b, and c are 
all integers.
(see my earlier timeit results)

/F 



___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Re: builtin_id() returns negative numbers

2005-02-19 Thread Fredrik Lundh
Donovan Baarda wrote:

 Apparently lawyers have decided that you can't give code away. Intellectual
 charity is illegal :-)

what else would a lawyer say?  do you really expect lawyers to admit that there
are ways to do things that don't involve lawyers?

/F 



___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] builtin_id() returns negative numbers

2005-02-19 Thread Martin v. Löwis
Donovan Baarda wrote:
Seriously, on the Python lists there has been a discussion rejecting an
md5sum implementation because the author donated it to the public domain.
Apparently lawyers have decided that you can't give code away. Intellectual
charity is illegal :-)
Despite the smiley: It is not illegal - it just does not have any legal
effect. Just by saying I am the chancellor of Germany, it does not
make you the chancellor of Germany; instead, you need to go through the
election processes. Likewise, saying the public can have my code does
not make it so. Instead, you have to formulate a license that permits
the public to do with the code what you think it should be allowed to
do. Most people who've used the term public domain in the past didn't
really care whether they still have the copyright - what they wanted
to say is that anybody can use their work for any purpose.
Regards,
Martin
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Re: Prospective Peephole Transformation

2005-02-19 Thread Aahz
On Sat, Feb 19, 2005, Martin v. L?wis wrote:
 Fredrik Lundh wrote:

I'd say that this explains why it would still make sense to let the code 
generator change
x in (a, b, c) to x == a or x == b or x == c, as long as a, b, and c 
are all integers.
 
 How often does that happen in real code?

Dunno how often, but I was working on some code at my company yesterday
that did that -- we use a lot of ints to indicate options.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death.  --GvR
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Requesting that a class be a new-style class

2005-02-19 Thread Guido van Rossum
  This is something I've typed way too many times:
 
  Py class C():
 File stdin, line 1
   class C():
   ^
  SyntaxError: invalid syntax
 
  It's the asymmetry with functions that gets to me - defining a
  function with no arguments still requires parentheses in the
  definition statement, but defining a class with no bases requires the
  parentheses to be omitted.

It's fine to fix this in 2.5. I guess I can add this to my list of
early oopsies -- although to the very bottom. :-)

It's *not* fine to make C() mean C(object). (We already have enough
other ways to declaring new-style classes.)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com