TG1 with Python2.6

2 views
Skip to first unread message

Yo'av Moshe

unread,
Nov 20, 2008, 7:00:36 PM11/20/08
to TurboGears
Hey,
I'm posting this so other people looking for a solution can find it
more easily. This is nothing official.

I'm developing an TG1 project for a while now, and since my linux
distro (Arch) started shipping Python 2.6 instead of Python 2.5 I
couldn't run my installation of TG1.0.7. Like most of you know,
RuleDispatch isn't compatible (yet?) with Python 2.6, so even after
reinstalling everything - TG1.0.7 won't load.

The good news is that TG1.1 doesn't need RuleDispatch, and works with
Python 2.6 (I'm having troubles running 'tg-admin shell' but other
than that all is good). The bad news is that 'easy_install turbogears'
won't get you TG1.1, since there's no py2.6-version-.egg file for it.

So, get the 1.1 branch from SVN:
svn co http://svn.turbogears.org/branches/1.1 turbogears

and easy_install it (this shall get all the dependencies right).

This way you'll be able to run TG1.1 using Python2.6, which seems
fully compatible with TG1 on Python2.5.

Hope this helps some! :)
Yo'av.

Florent Aide

unread,
Nov 20, 2008, 7:29:28 PM11/20/08
to turbo...@googlegroups.com
On Fri, Nov 21, 2008 at 1:00 AM, Yo'av Moshe <bje...@gmail.com> wrote:
>
> Hey,
> I'm posting this so other people looking for a solution can find it
> more easily. This is nothing official.

[...]

> So, get the 1.1 branch from SVN:
> svn co http://svn.turbogears.org/branches/1.1 turbogears
>
> and easy_install it (this shall get all the dependencies right).
>
> This way you'll be able to run TG1.1 using Python2.6, which seems
> fully compatible with TG1 on Python2.5.

Hum... SQLAlchemy does not work with python 2.6 and if you need JSON
support you'll have to fix quite a few places in the TG core core to
correctly import the new simplejson bundle with py26.

I'm sure you'll encounter a lot of issues here and there :)

I'm happy you're testing 1.1 with python 2.6, but please do not ask
people to use SVN checkouts, we are undergoing massive changes in the
SVN and we could break things at any time. We'll get a beta2 out of
the door in a few days (just waiting for some nice CSS templates and
we're good to go...). At that time I promise I'll put in place a
source tarball for the beta release so people can have an easy
snapshot.

In fact using TurboGears from the SVN or trying to port TG1.x to
python 2.6 are discussions that should happen in the trunk mailing
list IMHO.

Florent.

Yo'av Moshe

unread,
Nov 21, 2008, 5:17:43 AM11/21/08
to TurboGears
Well I'm using TG with Elixir and the latest devel version of
SQLAlchemy (0.5something), and it seem to be working. I haven't yet
tested my JSON calls.
I'm not recommending this setup to no-one, but if someone couldn't
continue developing like I was, it seem to be like a simple workaround
for meanwhile, at least until a tarball is out (sorry, I had no idea
it's a matter of days) :)

Yo'av.

Florent Aide

unread,
Nov 21, 2008, 6:32:34 AM11/21/08
to turbo...@googlegroups.com
On Fri, Nov 21, 2008 at 11:17 AM, Yo'av Moshe <bje...@gmail.com> wrote:
>
> Well I'm using TG with Elixir and the latest devel version of
> SQLAlchemy (0.5something), and it seem to be working. I haven't yet
> tested my JSON calls.

I'm happily surprised by this because I read a post by Mike Bayer a
few days ago saying that they would not support py26 before months...
because the dbapi backends were not yet ready.

What database backend are you using ? Because when you finally need to
go to production you cannot afford to rely on sqlite are you?

> I'm not recommending this setup to no-one, but if someone couldn't
> continue developing like I was, it seem to be like a simple workaround
> for meanwhile, at least until a tarball is out (sorry, I had no idea
> it's a matter of days) :)

Well you never know, when an open source developer says its a matter
of days you could wait for week ;)
Since you're using our 1.1Head I would be grateful if you could report
any glitch you find in it. Please do so in the trunk mailing list. We
are working hard those days to be able to release a nice beta2 and
your contribution would be greatly valued.

> Yo'av.

Florent.

Darren Govoni

unread,
Nov 22, 2008, 11:16:31 AM11/22/08
to turbo...@googlegroups.com
RE: simplejson

You guys should use cjson instead. It's 40x faster than simplejson.

Speed test here[1]

[1] http://lolrus.org/archives/61

Diez B. Roggisch

unread,
Nov 22, 2008, 11:30:57 AM11/22/08
to turbo...@googlegroups.com
On Saturday 22 November 2008 17:16:31 Darren Govoni wrote:
> RE: simplejson
>
> You guys should use cjson instead. It's 40x faster than simplejson.

As it doesn't have a pure-python-implementation, we'd be forced to use *two*
json-transcoders.

Besides, I guess the actual encoding time is dwarfed by the processing of the
whole request - think of all the generic method calls for jsonify.

In summary, this is of no real use for the general case - and those who need
to spit out huge amounts of json in a few places can simply install cjson &
then do in their respective controller action

@expose()
def fast_humongous_json_output(self):
return cjson.encode(some_data_structure)


Diez

Florent Aide

unread,
Nov 22, 2008, 11:30:06 AM11/22/08
to turbo...@googlegroups.com
On Sat, Nov 22, 2008 at 5:16 PM, Darren Govoni <dar...@ontrenet.com> wrote:
>
> RE: simplejson
>
> You guys should use cjson instead. It's 40x faster than simplejson.

Users who want cjson can always add it but we won't base TG on it. The
cjson license is LGPL and this may trip some people who would refuse
to base their development on software that incorporate LGPL pieces. I
don't want to start yet another licensing discussion here, and I
personnally base a lot of my work on lgpl software but this is not for
the TG developpers to force an lgpl dependence on it's users.

And since we are in a Python 2.6 related thread: simplejson is now in
the python standard library. Which is another reason to use simplejson
and keep it the one we require as a depence.

Florent.

Christopher Arndt

unread,
Nov 22, 2008, 12:19:43 PM11/22/08
to turbo...@googlegroups.com
Darren Govoni schrieb:

> RE: simplejson
>
> You guys should use cjson instead. It's 40x faster than simplejson.
>
> Speed test here[1]
>
> [1] http://lolrus.org/archives/61

This benchmark compares to a rather old version of simplejson.

With the current release of simplejson, I get these results:

(venv)chris@minimax:simplejson$ time python simplejsonbench.py

real 0m2.687s
user 0m2.081s
sys 0m0.126s
(venv)chris@minimax:simplejson$ time python cjsonbenchmark.py

real 0m1.212s
user 0m1.093s
sys 0m0.110s
(venv)chris@minimax:simplejson$ python -c "import simplejson; print
simplejson.__version__"
2.0.4
(venv)chris@minimax:simplejson$ python -c "import simplejson._speedups"
(venv)chris@minimax:simplejson$ python -c "import cjson; print
cjson.__version__"
1.0.5
(venv)chris@minimax:simplejson$ uname -a
Darwin minimax.paddyland.lan 8.11.1 Darwin Kernel Version 8.11.1: Wed
Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 i386
(venv)chris@minimax:simplejson$ system_profiler | head -n 13
Hardware:

Hardware Overview:

Model Name: Mac mini
Model Identifier: Macmini1,1
Processor Name: Intel Core Duo
Processor Speed: 1.83 GHz
Number Of Processors: 1
Total Number Of Cores: 2
L2 Cache (per processor): 2 MB
Memory: 2 GB
Bus Speed: 667 MHz

Don't believe a statistic which you haven't faked yourself!


Chris

Darren Govoni

unread,
Nov 22, 2008, 12:27:38 PM11/22/08
to turbo...@googlegroups.com
I actually got 40x returns when I switched to cjson in my own real-world
apps (alas I don't have a blog), but point taken by the other authors
that it can be used ad hoc. No problem!

Christopher Arndt

unread,
Nov 22, 2008, 12:44:08 PM11/22/08
to turbo...@googlegroups.com
Darren Govoni schrieb:

> I actually got 40x returns when I switched to cjson in my own real-world
> apps (alas I don't have a blog), but point taken by the other authors
> that it can be used ad hoc. No problem!

Which version of simplejson do you have? There are major speed
improvements since version 2.0.x!

Are you sure, the C extension is used? Can you do 'python -c "import
simplejson._speedups"' without errors?


Chris

Darren Govoni

unread,
Nov 22, 2008, 12:48:27 PM11/22/08
to turbo...@googlegroups.com
Not sure the version, I apt-get'd it in ubuntu 8.04 about 6 months ago
or thereabouts. Soon after, I found it was indeed the bottleneck of my
AJAX app, but glad to hear about the speed improvements.

Mark Ramm

unread,
Dec 2, 2008, 11:59:33 AM12/2/08
to turbo...@googlegroups.com
That's before the 2.0 speedups.

I think you'll find that the latest version of simplejson from the python package index is very much faster than the one you were using 6 months ago.

--Mark Ramm
--
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog

Reply all
Reply to author
Forward
0 new messages