Pprint module works slowly with Django in 32bits system
Question: I use Django on a 32 bits Ubuntu machine with Python 2.7. My development
server has been slow all the time, taking about 15 seconds to render any page.
I ran a cProfile test to see what works so slowly.

Seems that it's the pprint module.

Here's my statistics:

    
    
    ncalls       tottime percall cumtime percall filename:lineno(function)
    272605/48718  24.238       0  49.213   0.001 pprint.py:247(_safe_repr)
    

and this is my colleague's who runs 64 bits OS X:

    
    
    14531/5334    1.016    0.000    2.199    0.000 pprint.py:247(_safe_repr)
    

Meanwhile I have to turn off the debug mode to use the dev server normally.

Here's the profiling script:

    
    
    from cProfile import Profile
    from django.test.client import Client
    import Cookie
    cl = Client()
    cl.cookies = Cookie.SimpleCookie({'sessionid':'7344ebeba093b65c1d59a9d7583f60bc'})
    p = Profile()
    p.runctx("c.get('/welcome/')", globals={'c': cl}, locals={})
    p.print_stats()
    

(the sessionid cookie is used to show a page where you need to log in.)

**I'm not sure the 32bits system is the main reason.**

The main quesion is: **Why is pprint._safe_repr so slow in Python 2.7 32 bits
and fast in 64 bits?** and if I can set something to make it fast.


Answer: > Why is pprint._safe_repr so slow in Python 2.7 32 bits and fast in 64 bits?

It is not fast on 64 bits. Your colleague got much less `ncalls`.

You should investigate why a single GET leads to such a large number of calls
to `_safe_repr()`.

