Cheetah template tip: you want _namemapper for Windows
by Kevin Dangoor
I do most of my work on my Mac, hopping over to the PC for additional integration and build testing. I already have someone who is running Windows builds regularly, though, so any Windows-specific problems will get shaken out. I was testing out my latest build on Windows and found that it was very slow. I tossed a timer onto the page and found that it was taking 21 seconds to render. I added a database index I had been meaning to add, but I didn’t think that would do it because my database had a trivial amount of data.
That was when I remembered that the setup.py script for Cheetah assumes that you don’t have a C compiler if you’re running Windows. I’m working with enough modules that it was well worth getting a functional MinGW setup going. I changed Cheetah’s setup.py to enable the _namemapper C module.
The rendering time for that page dropped to 0.06 seconds, 350 times faster. It sure seems like you need _namemapper for any but the most trivial templates. Given that, I would probably make setup.py count on a C compiler first, and let the user comment out that line if they don’t have one.
If you’re considering using Cheetah under Windows, don’t call it “too slow” until you’ve tried it with C _namemapper.
Hey thanks, that’s something I didn’t know about and I was just considering doing some Cheetah work under windows.
Ditto here. I’m about to use cheetah on win32.
But if you could also give the change made to setup.py, that ‘d be terrific ! (so lazy I am …)
Going from memory here, because I don’t have the actual setup.py handy. Basically, there’s an if statement in there that checks if you’re running windows and if you are to *not* build _namemapper. (Or, it might be the inverse of that: build namemapper if you’re not on windows). Just change that so that it will always try to build it.
I’d be happy to toss a copy of _namemapper.pyd over to the Cheetah folks if they want to make it available.