On 10 January 2011 11:26, Nick Coghlan <ncoghlan@gmail.com> wrote:
On Mon, Jan 10, 2011 at 11:11 AM, Ron Adam <rrr@ronadam.com> wrote:
> On the python side of things, the attributes we've been discussing almost
> never have anything to do with what most programs are written to do. Unless
> it's a program written specifically for managing pythons various parts. It's
> kind of like the problem of separating content, context, and presentation in
> web pages.  Sometimes it's hard to do.

Yep - 99.99% of python code will never care if this is ever fixed.
However, the fact that we've started using acceleration modules and
pseudo-packages in the standard library means that "things should just
work" is being broken subtly in the stuff we're shipping ourselves
(either by creating pickling problems, as in unittest, or misleading
introspection results, as in functools and datetime).

And if we're going to fix it at all, we may as well fix it right :)

I certainly don't object to fixing this, and neither do I object to adding a new class / module / function attribute to achieve it.

However... is there anything else that this fixes? (Are there more examples "in the wild" where this would help?)

The unittest problem with pickling is real but likely to only affect a very, very small number of users. The introspection problem (getsource) for functools and datetime isn't a *real* problem because the source code isn't available. If in fact getsource now points to the pure Python version even in the cases where the C versions are being used then "fixing" this seems like a step backwards...

Python 3.2:
>>> import inspect
>>> from datetime import date
>>> inspect.getsource(date)
'class date:\n    """Concrete date type.\n\n ...'

Python 3.1:
>>> import inspect
>>> from datetime import date
>>> inspect.getsource(date)
Traceback (most recent call last):
IOError: source code not available

With your changes in place would Python 3.3 revert to the 3.1 behaviour here? How is this an advantage?

What I'm really asking is, is the cure (and the accompanying implementation effort and additional complexity to the Python object model) worse than the disease...

All the best,

Michael Foord


Nick Coghlan   |   ncoghlan@gmail.com   |   Brisbane, Australia


May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html