[Python-Dev] New and Improved Import Hooks

Neal Norwitz neal@metaslash.com
Tue, 3 Dec 2002 09:28:05 -0500


On Tue, Dec 03, 2002 at 11:48:29AM -0000, Moore, Paul wrote:
> 
> My view is that import.c is, indeed, very complex and difficult
> code to follow. 
> I agree with Just's comments that a cleanup in import.c would be
> useful. 

I agree with both of these statements.  I have reviewed the patch.
While it's quite involved, I don't think it's worth rejecting.
I would really like to see a cleanup, though.

Rejecting the patch would be worthwhile if the interface would need to
change after incorporating this patch.  I don't believe this is the
case.  Whether this patch is accepted or not wouldn't change future
patches that Just wants to incorporate.

> I think that the zipfile patch is close to being acceptable. I
> don't have a problem if it gets rejected, but can I make a plea
> - if it does, can it be "Rejected because patch XXX does the job
> better" rather than "Rejected because this can be implemented
> better using feature YYY".

Agreed.

I don't recall if there is a lot of code duplication for file handling
in import.c, there's certainly some.  But in reviewing bz2, there was
a lot of duplication.  Gustavo and I discussed reusing the file code.
Perhaps, PyFileObject could be refactored to make reuse easier in bz2
and import.

If Just incorporates his import patch, perhaps the zipfile code could
be refactored to use the more generic framework.  I don't view these
two patches as mutually exclusive.  If all of these issues are
addressed, the resulting code could be clearer, even if intermediate
versions are not.

Neal