Segmentio/encoding: optimized drop-in replacement for Go's encoding/JSON package
github.com
github.com
I love Requests, but this statement overreaches. All of my Python these days is simple scripting, and in those simple cases the hassle of adding a dependency outweighs the utility that Requests provides over the standard library. And I'd say Requests is even a special case here in that it's widely known and acknowledged; while I wager you can find superior third-party replacements to the Python standard library if you look for them, the fact that you don't need to look for them at all (and audit them, ideally!) is what makes a batteries-included language so convenient even in the presence of a sub-par stdlib.
if sys.version_info[0] == 2:
from urllib2 import urlopen, Request # python2
else:
from urllib.request import urlopen, Request # python3Go's standard encoding/json isn't great (for many reasons...), but it's definitely in the Good Enough category, and as such IMO falls under "if it ain't broken don't fix it" umbrella.
Normally.. you would hope that the great test system built in to go would benefit stdlib upgrades like this and allow you do them more easily and with greater confidence.. but if what you're implementing suffers from this, then you pretty much stuck locking yourself into specific implementations rather than general specifications.
> but it's definitely in the Good Enough category
"Two steps forward, one step back" sums up how I feel about Go. It's still my favorite user-mode language, though.
Edit: Then again, the authors advocate mildly against upstreaming it:
> For these reasons, we also don't believe that this code should be ported upsteam to the standard encoding/json package.
https://github.com/segmentio/encoding/tree/master/json#trade...
I've been using these packages with some success:
https://github.com/tidwall/sjson
https://github.com/tidwall/gjson
Not knocking this pkg, just thought I'd share xD
I think these sorts of challenges show that Go tends to be used in lower-level code than typical dynamic languages. I've combined three or four different approaches in several Go projects, which I couldn't imagine doing in a language like Python.