mLewisLogic/foursquare

Requests and ujson?

Closed this issue · 4 comments

Hi,

Is it possible to have foursquare default to use requests and ujson libraries?

Feel free to write pull requests for either of them (please keep them separate).

I would absolutely not require ujson, but perhaps you can send me a PR which uses it if it happens to be installed?

What do you feel the advantage of using the requests library is?

In this particular case, requests library could be used to replace the _process_request_with_httplib2 function with almost 0 mods other than excepting different exceptions.

In terms of ujson, I think you're right. Nesting a bunch of ImportError handling could be one solution so ujson can be used when available. But after some thoughts, I'd rather just monkey patch it by doing foursquare.json = ujson to be less intrusive :)

I'll try to come up with a PR for requests usage.

I actually wouldn't mind an ImportError solution for ujson. If it automatically patches itself over the built-in json that is.

Done! ujson and simplejson are both supported for performance boosts.
'requests' is now the underlying HTTP library as well.