[RFC] c modules in own directory?

Brendan Cully brendan at kublai.com
Wed May 20 01:30:38 CDT 2009


On Wednesday, 20 May 2009 at 08:18, Simon Heimberg wrote:
> What about moving all the C files (mercurial/*.c) in an own directory
> (example mercurial/c) and creating a small python file for each? The
> small python file would try to import the module from c. If this fails,
> it would import the one in pure. (See example in the end.)
> 
> The advantage is that executing hg is possible out of a repo without
> executing setup first. It is even possible to only build some modules in
> C.

This is also the disadvantage: 'pure' is much slower than C, so it
has been decided that it should not be used without the explicit
request of the user (e.g., by using setup.py --pure).

In fact, python naturally supports your scheme: it will automatically
load module.so instead of module.py if both exist in the same
location. Mercurial is jumping through hoops to prevent that from
happening.

> The first module loading would be a little bit longer than now.
> 
> setup.py could keep all the files or not copy the pure modules or delete
> the small python files and insert the c modules.
> setup.py --pure would not copy the directory mercurial/c or replace the
> small python files with those in pure.


More information about the Mercurial-devel mailing list