Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-08 Thread Phillip J. Eby
At 03:56 PM 12/8/2007 +1000, Nick Coghlan wrote: >Phillip J. Eby wrote: > >> > Does anyone else think this is an issue worth pursuing? > > > > A qualified yes: the Importing package took a long time to get correct > > under all the crazy little twists and turns of importing, including > > correctly

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-08 Thread Christian Heimes
Phillip J. Eby wrote: > Misc. notes for the PEP: there should be a way to determine the laziness > of a module object without causing it to load. I also think you should > be able to set a module's __loader__, __path__, and __file__, without > causing it to load. That way, you can create a lazy m

Re: [Python-3000] Method descriptors

2007-12-08 Thread Christian Heimes
Marcin ‘Qrczak’ Kowalczyk wrote: >BTW, applying PyMethod_Type to 3 arguments crashes Python3. I think >this line is the culprit (classobject.c): > > if (!PyArg_UnpackTuple(args, "method", 2, 3, > &func, &self)) > >Should be 2 instead of 3. There u

[Python-3000] Method descriptors

2007-12-08 Thread Marcin ‘Qrczak’ Kowalczyk
I'm confused about storing methods in class dictionaries from the point of view of the C API. 1. Let's say that I have a callable PyObject called f, of my type defined in C. I want to store something derived from f as A.m for some class A, such that for an object a of class A, calling a.m

Re: [Python-3000] PyInt_ to PyLong_ rename

2007-12-08 Thread Gregory P. Smith
heh ag On 12/7/07, Greg Ewing <[EMAIL PROTECTED]> wrote: > > Gregory P. Smith wrote: > > look at the length of a > > hex pointer in the repr of a class for C pointer size. > > I don't think that will work, because the repr only uses > as many hex digits as it needs to represent the value: > > >>>

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-08 Thread Brett Cannon
On Dec 8, 2007 7:32 AM, Christian Heimes <[EMAIL PROTECTED]> wrote: > Phillip J. Eby wrote: > > Misc. notes for the PEP: there should be a way to determine the laziness > > of a module object without causing it to load. I also think you should > > be able to set a module's __loader__, __path__, an

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-08 Thread Christian Heimes
Nick Coghlan wrote: > I'm far from convinced that a from-scratch rewrite (particularly in C) > is a great idea myself - that's why I suggested a PEP to look at some of > the issues. Yesterday I wrote down a quick survey of codes with some use cases. Then I compared my ideas with PJE's import too

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-08 Thread Phillip J. Eby
At 09:55 PM 12/8/2007 +0100, Christian Heimes wrote: >Nick Coghlan wrote: > > I'm far from convinced that a from-scratch rewrite (particularly in C) > > is a great idea myself - that's why I suggested a PEP to look at some of > > the issues. > >Yesterday I wrote down a quick survey of codes with so

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-08 Thread Christian Heimes
Nick Coghlan wrote: > With the new abstract base classes in Py3k, I can see it being > worthwhile to have a standard mechanism to allow callbacks to be > registered for execution when particular modules are first imported. > > For example, to handle the commented out case above: > >@imp.imp

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-08 Thread Christian Heimes
Phillip J. Eby wrote: > Note that in my implementation, an entry is added to sys.modules > immediately, so this scenario can't happen without *replacing* the > sys.modules entry. I like to separate the implementation of the post import hook from lazy modules. I think that the hook and lazy modul

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-08 Thread Phillip J. Eby
At 10:32 PM 12/8/2007 +0100, Christian Heimes wrote: >The pre import hook can probably be implemented in pure Python with a >meta path hook as described in http://www.python.org/dev/peps/pep-0302/. >I see the pre import hook as a lightweight meta path hook with an easy >to use interface. Which mea

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-08 Thread Phillip J. Eby
At 10:49 PM 12/8/2007 +0100, Christian Heimes wrote: >Phillip J. Eby wrote: > > Note that in my implementation, an entry is added to sys.modules > > immediately, so this scenario can't happen without *replacing* the > > sys.modules entry. > >I like to separate the implementation of the post import

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-08 Thread Greg Ewing
Phillip J. Eby wrote: > Lazy importing is putting a module object into sys.modules, but not > loading its contents until you attempt to get or set a module attribute. How is that expected to be useful? If you're not going to access any attributes of a module, why can you simply not import it in

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-08 Thread Phillip J. Eby
At 12:37 PM 12/9/2007 +1300, Greg Ewing wrote: >Phillip J. Eby wrote: > > > Lazy importing is putting a module object into sys.modules, but not > > loading its contents until you attempt to get or set a module attribute. > >How is that expected to be useful? If you're not going >to access any attri

[Python-3000] bsddb185 v1.0 for Python 2.6 and 3.0

2007-12-08 Thread skip
Python 3.0 will dispense with the rarely used, but occasionally indispensible, bsddb185 module. I extracted the source code and unit tests from the current Python trunk, wrote a setup.py, made a couple slight mods so it would build and pass tests under both Python 2.6 and 3.0. It's available fro