[racket] How can I speed up this code?

From: J G Cho (gcho at fundingmatters.com)
Date: Mon Jan 14 11:12:55 EST 2013

Dear performance experts,

With the news of math library in Racket and the goal of improving my
data analysis skill, I have started going over the examples in book
"Python for Data Anyalysis" by McKinney using both Python and Racket.
Too early to tell which is preferable for me. But I do have one
"problem" with Racket that I would like to resolve before going on
further.

Here is the detail.

Python:

First I load the data

# It looks like this at the top level;
# structured differently from the example in the book.
data_set = {
"meta": {},
"data": []
}

import json

# read in the json data downloaded from
# https://explore.data.gov/Information-and-Communications/1-USA-gov-Short-Links/wzeq-n5pg
with open("usagov_bitly_data.json") as f:
    data_set = json.load( f )


And then I go do the usual slice and dice....

My work flow is to edit the file and either run it inside Sublime Text
2 or ipython --pylab. (v 2.7 via EPD package running on Win 7 on
fairly new and powerful Dell.) There is a brief pause before I see the
output in the screen.



I run the following in DrRacket (v5.3):

#lang racket

(require json)

(define data-set
  (call-with-input-file "usagov_bitly_data.json"
    (lambda (in)
      (read-json in))))


It takes sometime (more than a few sips of tea) where edit-run cycle
is not workable.

I initially thought maybe the json library was the cause and tried
writing the parsed data out as .sexp and then reading that in. It did
not resolve the speed issue for me. I now work with a smaller subset
of data when I work with Racket.

Any suggestions?

jGc

Posted on the users mailing list.