[issue35914] [2.7] PyStructSequence objects not behaving like nametuple

2019-02-06 Thread Eric Snow
Eric Snow added the comment: Sounds good. I hope that helped. -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ _

[issue35914] [2.7] PyStructSequence objects not behaving like nametuple

2019-02-06 Thread Xiang Gao
Xiang Gao added the comment: Hi Eric, Thanks for your valuable information and fast reply. You understand the problem exactly correct: initially pytorch had codes like `isinstance(x, tuple)` and lots of `PyTuple_Check`, but when we start to change the return type from tuple to structseq, th

[issue35914] [2.7] PyStructSequence objects not behaving like nametuple

2019-02-06 Thread Eric Snow
Eric Snow added the comment: FWIW, if folks *are* checking for tuple (and I'd love to know why) then I'd recommend that they not. :) A more Pythonic (and arguably generally better) approach would be to stick tightly to what data you need and take advantage of duck-typing. When possible, tr

[issue35914] [2.7] PyStructSequence objects not behaving like nametuple

2019-02-06 Thread Eric Snow
Eric Snow added the comment: [1] https://devguide.python.org/#status-of-python-branches -- ___ Python tracker ___ ___ Python-bugs-l

[issue35914] [2.7] PyStructSequence objects not behaving like nametuple

2019-02-06 Thread Eric Snow
Eric Snow added the comment: tl;dr It's too late to change anything here. Also, is it actually a problem in practice? At this point enhancements can not go into 2.7 (you're welcome to appeal to the release manager). The changes to `PyStructSequence` (from bpo-1820) appear to have be

[issue35914] [2.7] PyStructSequence objects not behaving like nametuple

2019-02-06 Thread Xiang Gao
New submission from Xiang Gao : Related: https://bugs.python.org/issue1820 On issue 1820, a bunch of improvements was made on PyStructSequence to make it behave like a namedtuple. These improvements are not ported to Python 2, which makes it a trouble to write python 2-3 compatible code. See