Hacker News new | past | comments | ask | show | jobs | submit login

Great that you promote requests, lxml, json (just json, not simplejson since Python 2.6), django to use by a beginner in Python. Pages from http://wiki.python.org/moin/WebProgramming might provide too much choice for a beginner.

You might add a tiny example of a microframework such as Bottle, Flask or an example from Pyramid written in the microframework-ish style.

Recommending `sudo` with `pip install` to a novice is not a good idea. System package manager or `pip install --user` could be used as alternatives. `virtualenv` might be out of topic for a short tutorial.




About JSON: Python 2.6 added a "json" module to the standard library that was forked from simplejson, but in that time, simplejson has improved; the interface is exactly the same as the built-in json module, but simplejson tends to be quite a bit faster.

On my informal benchmark of JSON parsing speed, simplejson was 27x faster than json.

The idiom I've been using is:

    try:
      import simplejson as json
    except ImportError:
      import json


Documentation for simplejson mentions that it should be faster. Though it contains reference to Python 2.5, 2.6 so It is unclear whether the claim is outdated:

It is the externally maintained version of the json library contained in Python 2.6, but maintains compatibility with Python 2.5 and (currently) has significant performance advantages, even without using the optional C extension for speedups. </quote> http://simplejson.readthedocs.org/en/latest/index.html

I see there are performance patches to stdlib's json since 2.6: http://hg.python.org/cpython/search/?rev=_json.c&revcoun...

An order of magnitude difference might be an issue with your python installation.

On my machine version from 2.6 (1.9) is 15 times slower than from 2.7 (2.0.9). Though simplejson (2.2.1) is still faster on both 40 and 2 times correspondingly for .loads() timeline.js from the example as measured by:

  % timeit json.loads(timeline_text)
it seems that C speedups available on both versions:

  python -v -c'import json' 2>&1 | grep _json.so
  python -c'import json.decoder as d; print d.scanstring'
Is your python version old? Otherwise it is worth to open issues at http://bugs.python.org to merge speed improvements and at https://github.com/simplejson/simplejson/issues to mention in the docs and on http://pypi.python.org/pypi/simplejson more clearly that Python 2.7+ stdlib's version is also slower.


I'm stuck on 2.6 for now, so that's probably the main issue.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: