Remove isinstance() check for namedtuple_as_object #22

Merged
merged 2 commits into from Dec 5, 2011

Projects

None yet

2 participants

@singingwolfboy
Contributor

Using isinstance() is not Pythonic and should be avoided when possible.
By using duck-typing instead, we can easily support other objects
that do not inherit from tuple but still support the same API as
namedtuple, such as objects created using the recordtype library:
http://pypi.python.org/pypi/recordtype

singingwolfboy added some commits Nov 11, 2011
@singingwolfboy singingwolfboy Removed isinstance() check for namedtuple_as_object
Using isinstance() is not Pythonic and should be avoided when possible.
By using duck-typing instead, we can easily support other objects
that do not inherit from tuple but still support the same API as
namedtuple, such as objects created using the `recordtype` library:
http://pypi.python.org/pypi/recordtype
698e6c1
@singingwolfboy singingwolfboy Removed PyTuple_Check from _is_namedtuple() in _speedups.c edfa765
@etrepum
Member
etrepum commented Nov 18, 2011

This seems like a reasonable thing to do, but I will need some tests and updates to docs (index.rst) to reflect the change. Do you want to do this? If not, I'll get around to it in the next few weeks.

@etrepum
Member
etrepum commented Nov 19, 2011

Take a look at this branch, includes your changes and I added some docs and tests. Had a bit more time than I expected today. master...namedtuple_duck-gh22

@singingwolfboy
Contributor

Looks good to me! Sorry it took me so long to get back to this. Do you need me to do anything to get this merged into master?

@etrepum etrepum merged commit edfa765 into simplejson:master Dec 5, 2011
@jperkin jperkin pushed a commit to joyent/pkgsrc that referenced this pull request Dec 9, 2013
wiz Update to 2.5.2:
Version 2.5.2 released 2012-05-10

* Fix for regression introduced in 2.5.1
  simplejson/simplejson#35

Version 2.5.1 released 2012-05-10

* Support for use_decimal=True in environments that use Python
  sub-interpreters such as uWSGI
  simplejson/simplejson#34

Version 2.5.0 released 2012-03-29

* New item_sort_key option for encoder to allow fine grained control of sorted
  output

Version 2.4.0 released 2012-03-06

* New bigint_as_string option for encoder to trade JavaScript number precision
  issues for type issues.
  simplejson/simplejson#31

Version 2.3.3 released 2012-02-27

* Allow unknown numerical types for indent parameter
  simplejson/simplejson#29

Version 2.3.2 released 2011-12-30

* Fix crashing regression in speedups introduced in 2.3.1

Version 2.3.1 released 2011-12-29

* namedtuple_as_object now checks _asdict to ensure that it
  is callable.
  simplejson/simplejson#26

Version 2.3.0 released 2011-12-05

* Any objects with _asdict() methods are now considered for
  namedtuple_as_object.
  simplejson/simplejson#22
6bc94ea
@jsonn jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Oct 11, 2014
wiz Update to 2.5.2:
Version 2.5.2 released 2012-05-10

* Fix for regression introduced in 2.5.1
  simplejson/simplejson#35

Version 2.5.1 released 2012-05-10

* Support for use_decimal=True in environments that use Python
  sub-interpreters such as uWSGI
  simplejson/simplejson#34

Version 2.5.0 released 2012-03-29

* New item_sort_key option for encoder to allow fine grained control of sorted
  output

Version 2.4.0 released 2012-03-06

* New bigint_as_string option for encoder to trade JavaScript number precision
  issues for type issues.
  simplejson/simplejson#31

Version 2.3.3 released 2012-02-27

* Allow unknown numerical types for indent parameter
  simplejson/simplejson#29

Version 2.3.2 released 2011-12-30

* Fix crashing regression in speedups introduced in 2.3.1

Version 2.3.1 released 2011-12-29

* namedtuple_as_object now checks _asdict to ensure that it
  is callable.
  simplejson/simplejson#26

Version 2.3.0 released 2011-12-05

* Any objects with _asdict() methods are now considered for
  namedtuple_as_object.
  simplejson/simplejson#22
b0726e7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment