JSON data

25 views
Skip to first unread message

palansh agarwal

unread,
May 6, 2015, 5:19:51 PM5/6/15
to django...@googlegroups.com
Hello,
I am making a django app in which I require to read json data from an external API and display data, But it's working very slowly. Any suggestions to speed up the process will be appreciated.
Regards,

--
PALANSH AGARWAL
Y13UC185
Computer Science Engineering
2nd Year
The LNM Institute of Information Technology, Jaipur

Tim Chase

unread,
May 6, 2015, 5:27:03 PM5/6/15
to django...@googlegroups.com, palansh...@gmail.com
On 2015-05-07 02:14, palansh agarwal wrote:
> I am making a django app in which I require to read json data from
> an external API and display data, But it's working very slowly. Any
> suggestions to speed up the process will be appreciated.

which part is slow? the API, the processing of the JSON, or the
display?

-tkc





Thomas Levine

unread,
May 7, 2015, 9:51:34 AM5/7/15
to django...@googlegroups.com, palansh...@gmail.com
> which part is slow? the API, the processing of the JSON, or the
> display?

And here's how you can check that. Insert the following line between
the different steps that Tim itemized,

print(time.perf_counter())

subtract the numbers that get printed, and then determine which step
is slow.

Alternatively, if your code is written very cleanly, you can use timeit.
https://docs.python.org/3/library/timeit.html

Tom

Tim Chase

unread,
May 7, 2015, 11:37:31 AM5/7/15
to palansh agarwal, django...@googlegroups.com
On 2015-05-07 13:56, palansh agarwal wrote:
> processing of json is slow. It takes considerable amount of time to
> process data after calling the API.

You seem fairly confident in this. Do you have the timing
statistics? Can you provide sample JSON data that others can use
for testing? Which version of Python are you using and which Python
JSON library are you using?

-tkc



Thorsten Sanders

unread,
May 7, 2015, 4:32:59 PM5/7/15
to django...@googlegroups.com
The version of python can make quite a big difference, years ago with
python 2.6 I had the problem that decoding several megabyte of json data
took over 1 minute with the integrated one, simplejson fixed that (only
took a few hundred ms) and since 2.7 it works fine with the integrated
one as well.

Tim Chase

unread,
May 7, 2015, 4:42:35 PM5/7/15
to django...@googlegroups.com, thorsten...@gmx.net
On 2015-05-07 22:32, Thorsten Sanders wrote:
> Am 07.05.2015 17:37, schrieb Tim Chase:
>> Can you provide sample JSON data that others can use
>> for testing? Which version of Python are you using and which
>> Python JSON library are you using?
>
> The version of python can make quite a big difference, years ago
> with python 2.6 I had the problem that decoding several megabyte of
> json data took over 1 minute with the integrated one, simplejson
> fixed that (only took a few hundred ms) and since 2.7 it works fine
> with the integrated one as well.

I remember there being various JSON libraries over time, and that
there were some performance issues in some of them (thus that bit of
my line of questioning) but didn't remember the particulars. Thanks
for filling in the details.

-tkc



Reply all
Reply to author
Forward
0 new messages