Re: [Python-Dev] A proposal: configuring logging using dictionaries

2009-10-18 Thread Vinay Sajip
Nick Coghlan  gmail.com> writes:

> My other question is whether or not it would be worth having the logging
> module able to export it's *current* configuration in dictionary form. I
> don't have a use case other than that it might be useful for debugging
> logging configuration errors when attempting to combine multiple sources
> of logging data, but it's worth considering.
> 

One restriction on any output of the current configuration is that it may not be
suitable for round-tripping, i.e. you may not be able to use the output dict to
(re)configure the system. That's because in general, the configurator wants to
know how to instantiate handlers, filters, formatters and so it essentially
needs the constructor arguments in an incoming dict. However, there's no
requirement for the handlers, filters and formatters to keep those constructor
arguments around in the original form; and so, in the general case, they are not
available to output in a dict describing the current configuration.

Regards,

Vinay Sajip

___
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] nonstandard behavior of reflected functions

2009-10-18 Thread Darren Dale
According to http://docs.python.org/reference/datamodel.html , the
reflected operands functions like __radd__ "are only called if the
left operand does not support the corresponding operation and the
operands are of different types. [3] For instance, to evaluate the
expression x - y, where y is an instance of a class that has an
__rsub__() method, y.__rsub__(x) is called if x.__sub__(y) returns
NotImplemented."

Consider the following simple example:

==
class Quantity(object):

def __add__(self, other):
return '__add__ called'

def __radd__(self, other):
return '__radd__ called'

class UnitQuantity(Quantity):

def __add__(self, other):
return '__add__ called'

def __radd__(self, other):
return '__radd__ called'

print 'Quantity()+Quantity()', Quantity()+Quantity()
print 'UnitQuantity()+UnitQuantity()', UnitQuantity()+UnitQuantity()
print 'UnitQuantity()+Quantity()', UnitQuantity()+Quantity()
print 'Quantity()+UnitQuantity()', Quantity()+UnitQuantity()
==

The output should indicate that __add__ was called in all four trials,
but the last trial calls __radd__. Interestingly, if I comment out the
definition of __radd__ in UnitQuantity, then the fourth trial calls
__add__ like it should.

I think this may be an important bug. I'm running Python 2.6.4rc1
(r264rc1:75270, Oct 13 2009, 17:02:06) an ubuntu Karmic. Is it a known
issue, or am I misreading the documentation?

Thanks,
Darren
___
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] nonstandard behavior of reflected functions

2009-10-18 Thread Darren Dale
On Sun, Oct 18, 2009 at 10:50 AM, Darren Dale  wrote:
> According to http://docs.python.org/reference/datamodel.html , the
> reflected operands functions like __radd__ "are only called if the
> left operand does not support the corresponding operation and the
> operands are of different types. [3] For instance, to evaluate the
> expression x - y, where y is an instance of a class that has an
> __rsub__() method, y.__rsub__(x) is called if x.__sub__(y) returns
> NotImplemented."
>
> Consider the following simple example:
>
> ==
> class Quantity(object):
>
>    def __add__(self, other):
>        return '__add__ called'
>
>    def __radd__(self, other):
>        return '__radd__ called'
>
> class UnitQuantity(Quantity):
>
>    def __add__(self, other):
>        return '__add__ called'
>
>    def __radd__(self, other):
>        return '__radd__ called'
>
> print 'Quantity()+Quantity()', Quantity()+Quantity()
> print 'UnitQuantity()+UnitQuantity()', UnitQuantity()+UnitQuantity()
> print 'UnitQuantity()+Quantity()', UnitQuantity()+Quantity()
> print 'Quantity()+UnitQuantity()', Quantity()+UnitQuantity()
> ==
>
> The output should indicate that __add__ was called in all four trials,
> but the last trial calls __radd__. Interestingly, if I comment out the
> definition of __radd__ in UnitQuantity, then the fourth trial calls
> __add__ like it should.
>
> I think this may be an important bug. I'm running Python 2.6.4rc1
> (r264rc1:75270, Oct 13 2009, 17:02:06) an ubuntu Karmic. Is it a known
> issue, or am I misreading the documentation?

I'm sorry, I should have read further down the page in the documentation:

"Note: If the right operand’s type is a subclass of the left operand’s
type and that subclass provides the reflected method for the
operation, this method will be called before the left operand’s
non-reflected method. This behavior allows subclasses to override
their ancestors’ operations."
___
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] SIGCHECK() in longobject.c

2009-10-18 Thread Antoine Pitrou

Hello,

In Objects/longobject.c, there's the SIGCHECK() macro which periodically checks
for signals when doing long integer computations (divisions, multiplications).
It does so by messing with the _Py_Ticker variable.

It was added in 1991 under the title "Many small changes", and I suppose it was
useful back then.

However, nowadays long objects are ridiculously fast, witness for example:

$ ./py3k/python -m timeit -s "a=eval('3'*1+'5');b=eval('8'*6000+'7')"
"str(a//b)"
1000 loops, best of 3: 1.47 msec per loop

Can we remove this check, or are there people doing million-digits calculations
they want to interrupt using Control-C ?

Regards

Antoine.


___
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] SIGCHECK() in longobject.c

2009-10-18 Thread Mark Dickinson
On Sun, Oct 18, 2009 at 9:01 PM, Antoine Pitrou  wrote:

> In Objects/longobject.c, there's the SIGCHECK() macro which periodically 
> checks
> for signals when doing long integer computations (divisions, multiplications).
> It does so by messing with the _Py_Ticker variable.
>
> It was added in 1991 under the title "Many small changes", and I suppose it 
> was
> useful back then.
>
> However, nowadays long objects are ridiculously fast, witness for example:
>
> $ ./py3k/python -m timeit -s "a=eval('3'*1+'5');b=eval('8'*6000+'7')"
> "str(a//b)"
> 1000 loops, best of 3: 1.47 msec per loop
>
> Can we remove this check, or are there people doing million-digits 
> calculations
> they want to interrupt using Control-C ?

Yes, I suspect there are.  Though you don't need millions of digits for a single
operation to take a noticeable amount of time:  try str(10**10),
for example.

Is there a benefit to removing the check?

Mark
___
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] SIGCHECK() in longobject.c

2009-10-18 Thread Antoine Pitrou
Mark Dickinson  gmail.com> writes:
> 
> Yes, I suspect there are.  Though you don't need millions of digits for a
single
> operation to take a noticeable amount of time:  try str(10**10),
> for example.
> 
> Is there a benefit to removing the check?

Apart from casual cleanup, the reason I'm asking is that I'm experimenting with
removing _Py_Ticker, and I want to know what I need to emulate :-)


Antoine.


___
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] nonstandard behavior of reflected functions

2009-10-18 Thread Ehsan Amiri
I see the same behaviour, moreover when I change class Quantity to a classic
class (removing '(object)'), it works as expected. (i.e. Quanitity.__add__()
is called after the fourth print. I run Python 2.6.2 on Vista.






On Sun, Oct 18, 2009 at 7:50 AM, Darren Dale  wrote:

> According to http://docs.python.org/reference/datamodel.html , the
> reflected operands functions like __radd__ "are only called if the
> left operand does not support the corresponding operation and the
> operands are of different types. [3] For instance, to evaluate the
> expression x - y, where y is an instance of a class that has an
> __rsub__() method, y.__rsub__(x) is called if x.__sub__(y) returns
> NotImplemented."
>
> Consider the following simple example:
>
> ==
> class Quantity(object):
>
>def __add__(self, other):
>return '__add__ called'
>
>def __radd__(self, other):
>return '__radd__ called'
>
> class UnitQuantity(Quantity):
>
>def __add__(self, other):
>return '__add__ called'
>
>def __radd__(self, other):
>return '__radd__ called'
>
> print 'Quantity()+Quantity()', Quantity()+Quantity()
> print 'UnitQuantity()+UnitQuantity()', UnitQuantity()+UnitQuantity()
> print 'UnitQuantity()+Quantity()', UnitQuantity()+Quantity()
> print 'Quantity()+UnitQuantity()', Quantity()+UnitQuantity()
> ==
>
> The output should indicate that __add__ was called in all four trials,
> but the last trial calls __radd__. Interestingly, if I comment out the
> definition of __radd__ in UnitQuantity, then the fourth trial calls
> __add__ like it should.
>
> I think this may be an important bug. I'm running Python 2.6.4rc1
> (r264rc1:75270, Oct 13 2009, 17:02:06) an ubuntu Karmic. Is it a known
> issue, or am I misreading the documentation?
>
> Thanks,
> Darren
> ___
> 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/ehsanamiri%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


Re: [Python-Dev] SIGCHECK() in longobject.c

2009-10-18 Thread Daniel Stutzbach
On Sun, Oct 18, 2009 at 3:01 PM, Antoine Pitrou  wrote:

> Can we remove this check, or are there people doing million-digits
> calculations
> they want to interrupt using Control-C ?
>

I sometimes do million-digits calculations that I want to interrupt using
Control-C.

(particularly when I didn't *intend* to do a million-digits calculation...
;) )

--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC 
___
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] SIGCHECK() in longobject.c

2009-10-18 Thread Antoine Pitrou
Daniel Stutzbach  stutzbachenterprises.com> writes:
> 
> I sometimes do million-digits calculations that I want to interrupt using
Control-C.(particularly when I didn't *intend* to do a million-digits
calculation... ;) )--

Sure, but it's no different than doing, e.g.:
list(range(1)).sort()

(don't try this, it just made by computer slow down to a crawl and I had to kill
-9 the Python interpreter)

The question is whether there is still any reason to special-case long objects
and not, say, list.sort() or re.sub().

Regards

Antoine.


___
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] SIGCHECK() in longobject.c

2009-10-18 Thread Daniel Stutzbach
On Sun, Oct 18, 2009 at 5:46 PM, Antoine Pitrou  wrote:

> Daniel Stutzbach  stutzbachenterprises.com> writes:
> > I sometimes do million-digits calculations that I want to interrupt using
> Control-C.(particularly when I didn't *intend* to do a million-digits
> calculation... ;) )--
>
> Sure, but it's no different than doing, e.g.:
>list(range(1)).sort()
>

That's a good point, although I can't recall the last time I accidently
created a painfully large list.  I can recall the last time I started a
painfully large integer computation.

Being able to stop the interpretter with Control-C instead of kill -9 is a
minor convenience, though.  I could live without it.  (Although I can't
speak for everyone, of course)

--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC 
___
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] nonstandard behavior of reflected functions

2009-10-18 Thread Nick Coghlan
Ehsan Amiri wrote:
> I see the same behaviour, moreover when I change class Quantity to a
> classic class (removing '(object)'), it works as expected. (i.e.
> Quanitity.__add__() is called after the fourth print. I run Python 2.6.2
> on Vista.

Darren found the explanation further down the page he was reading - the
fact that the right operand is an instance of a subclass of the left
operand's class makes a difference.

Regards,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
---
___
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] Python 2.6.4rc2

2009-10-18 Thread Barry Warsaw

Hello everyone.

The source tarballs and Windows installers for Python 2.6.4rc2 are now  
available:


http://www.python.org/download/releases/2.6.4/

Please download them, install them, and try to use them with your  
projects and environments.  Let's make 2.6.4 a rock solid release!  If  
there are no more regressions found, we'll do the final release in one  
week, on 25-October.


Enjoy,
-Barry



PGP.sig
Description: This is a digitally signed message part
___
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] Proposal : Python Trusted Computing API

2009-10-18 Thread Abhiram Kasina
Hi

Trusted Computing (TC) is a technology developed and promoted by the Trusted
Computing Group (TCG)[3]. So, basically the group came up with these chips
called TPM chips which are present on most motherboards nowadays. The main
purpose of it is to enhance security so that infected executables don't run.
It also provides memory curtaining such that cryptographic keys won't be
accessible and many other features. There was a criticism on this from the
FOSS community as well that it enables DRM. No wonder, it is being pushed by
Intel, Microsoft, AMD, etc.. But personally I think its a good idea from
security point of view.

So, currently there is an TSS (TCG Software Stack)[1] API written in C. And
TrustedJava[2] is a project which ported it to Java and is going to be
included in the standard API of Java soon. They have 2 versions of it. One
is a simple wrapper on top of the API and the other is a whole
implementation of the stack in Java.

My proposal is we create an API for it in python.
*Reason*: I am a developer in Umit and I think Python is a very good
platform for developing applications. So, why not create an API which helps
in developing secure applications?

I would love to learn more and provide you with any more information. Please
let me know what you guys think of it?

Thanks in advance

Cheers
Abhiram

[1]
http://www.trustedcomputinggroup.org/resources/tcg_software_stack_tss_specification
[2] http://trustedjava.sourceforge.net/index.php?item=jtss/about
[3] http://www.trustedcomputinggroup.org/
___
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