Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Better hierarchy for importing JSON. Simplejson is faster than the builtin "json" due to the compiled C _speedups module. #20

Merged
merged 1 commit into from

2 participants

@mattrobenolt

Not much to explain. Simplejson + _speedups is much faster than default JSON, so it should be preferred when importing.

And lastly, falls back to Django's implementation as a last effort in-case both imports fail, but they're using the module from with Django.

@themartorana themartorana merged commit 52977a7 into themartorana:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 13, 2012
  1. @mattrobenolt

    Better hierarchy for importing JSON. Simplejson is faster than the bu…

    mattrobenolt authored
    …ilt in "json" due to the compiled C _speedups module.
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 3 deletions.
  1. +7 −3 postmark/core.py
View
10 postmark/core.py
@@ -19,12 +19,16 @@
import httplib
try:
- import json
+ import simplejson as json
except ImportError:
try:
- import simplejson as json
+ import json
except ImportError:
- raise Exception('Cannot use python-postmark library without Python 2.6 or greater, or Python 2.4 or 2.5 and the "simplejson" library')
+ try:
+ # Last ditch effort to try and grab it from Django if they're using Django
+ from django.utils import simplejson as json
+ except ImportError:
+ raise Exception('Cannot use python-postmark library without Python 2.6 or greater, or Python 2.4 or 2.5 and the "simplejson" library')
class PMJSONEncoder(json.JSONEncoder):
def default(self, o):
Something went wrong with that request. Please try again.