[issue7944] Use the 'with' statement in conjunction with 'open' throughout test modules
Raymond Hettinger added the comment: I'm not sure that this is a worthwhile exercise unless it can be shown for certain that alternate implementations need this. Otherwise, it just changes tests in a way that isn't backwards compatible, makes it more difficult to apply patches cleanly, and risks damaging an otherwise good test. -- nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue7944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7944] Use the 'with' statement in conjunction with 'open' throughout test modules
Changes by Raymond Hettinger : -- resolution: accepted -> ___ Python tracker <http://bugs.python.org/issue7944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7944] Use the 'with' statement in conjunction with 'open' throughout test modules
Raymond Hettinger added the comment: If you're sure that is still the case, this can proceed. -- ___ Python tracker <http://bugs.python.org/issue7944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10049] Add a "no-op" (null) context manager to contextlib
Raymond Hettinger added the comment: > To me, this is more a matter of conceptual completeness > than one of practical utility ... Nick, you don't seem to be truly sold on the need. I'm -1 on adding this. It's basically cruft. If it were published as an ASPN recipe, its uptake would be nearly zero. We need to focus on real problems in the standard library and provide solid solutions. If weight gets added to the standard lib, it needs to be selective. -- ___ Python tracker <http://bugs.python.org/issue10049> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10110] Queue doesn't recognize it is full after shrinking maxsize
Changes by Raymond Hettinger : -- assignee: -> rhettinger priority: normal -> low ___ Python tracker <http://bugs.python.org/issue10110> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5150] IDLE to support reindent.py
Raymond Hettinger added the comment: There's no need to go to python-dev or python-ideas with this one. If someone wants to figure-out a way to add reindent functionality to IDLE, patches are welcome. -- ___ Python tracker <http://bugs.python.org/issue5150> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10110] Queue doesn't recognize it is full after shrinking maxsize
Raymond Hettinger added the comment: I've briefly looked at the patch and it seems reasonable. Will look it in more detail by 3.2 goes out. I'm curious about your use case for wanting to change the maxsize of an existing Queue that is already in use. That seems like a odd design. -- ___ Python tracker <http://bugs.python.org/issue10110> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10110] Queue doesn't recognize it is full after shrinking maxsize
Raymond Hettinger added the comment: That won't be necessary. The change from == to <= is innocuous. There's no need to lock-up maxsize in a read-only property. We're consenting adults. Besides, it would probably break someone-else's odd use case. I don't want to expand the API, nor do I want to cripple anyone's ability to do weird stuff with it. FWIW, the full() and empty() methods are usually not a good idea. It's better to catch a Full exception. Otherwise, the information can be out of date by the time you try to use it. I'm going to mark this as a 3.2 only change. There were no guarantees about the behavior when maxsize is changed, nor should we make such guarantees. -- versions: -Python 2.7, Python 3.1 ___ Python tracker <http://bugs.python.org/issue10110> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5729] Allows tabs for indenting JSON output
Changes by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker <http://bugs.python.org/issue5729> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9778] Make hash values the same width as a pointer (or Py_ssize_t)
Raymond Hettinger added the comment: My expectation is that Py_hash_t is the same as Py_ssize_t. The goal is to make hashes match the range of possible table sizes. -- ___ Python tracker <http://bugs.python.org/issue9778> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10091] ast.literal_eval does not handled new set literals
Raymond Hettinger added the comment: ast.literal_eval's docs: 'The string or node provided may only consist of the following Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and None.' -- resolution: out of date -> invalid ___ Python tracker <http://bugs.python.org/issue10091> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10142] Support for SEEK_HOLE/SEEK_DATA
Raymond Hettinger added the comment: Martin, any thoughts on adding a ZFS dependent feature? ISTM this Solaris feature hasn't taken hold elsewhere and it may be a mistake to immortalize it in Python. -- assignee: -> loewis nosy: +loewis, rhettinger ___ Python tracker <http://bugs.python.org/issue10142> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10142] Support for SEEK_HOLE/SEEK_DATA
Raymond Hettinger added the comment: Jesús, can you attach a patch (with the appropriate #ifdefs)? -- ___ Python tracker <http://bugs.python.org/issue10142> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10160] operator.attrgetter slower than lambda after adding dotted names ability
Raymond Hettinger added the comment: Thanks for noticing this. I wasn't aware that it had slowed down after dotted name support had been added. Since it is a mild performance issue, I'm lowering the priority. Will take a further look when I get the chance. A first look at the patch shows that it is bigger than I expected. Isn't it possible to check for a dot on construction and just record the boolean so that a fast, non-splitting path can be used. I'm reluctant to make the code volume grow much for this function. It is already a bit voluminous for the minor convenience it offers. -- priority: normal -> low stage: -> patch review type: -> performance ___ Python tracker <http://bugs.python.org/issue10160> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10178] PEP 378 uses replace where translate may work better
Raymond Hettinger added the comment: Sorry, the text needs to stand as-is. It is supposed to be a hint of what can be done, nothing more. The technique of t=x; x=y; y=t is somewhat basic and has general applicability -- there's nothing "complex" about it. Also, for short strings such as the one in the example, the translate approach is slower unless the used in a loop where the translation table is already built. BTW, the PEP itself is not primary documentation for users. It is meant to document the design discussion only. Feel free to post your recipe on ASPN or on the newsgroup. -- resolution: -> rejected status: open -> closed ___ Python tracker <http://bugs.python.org/issue10178> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: [issue10199] Move Demo/turtle under Lib/
On Oct 26, 2010, at 10:05 AM, Alexander Belopolsky wrote: > > Alexander Belopolsky added the comment: > > On Tue, Oct 26, 2010 at 12:31 PM, Guido van Rossum >> Also many people don't expect to find any code in a file named __init__.py >> (and most of the time I >> agree with this). > > Well, logging, tkinter, and ctypes are clearly counterexamples to this rule. Those are not in the same league. Guido's point is that there are some disadvantages to making a package (i.e. the __init__.py files are an acquired taste), so we typically only do it when there are significant offsetting advantages. Just because a successful case for packaging was made for tkinter, doesn't mean that it is the right thing to do for the turtle module. As a general rule, *most* of the time a package is not the preferred solution. Raymond ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10199] Move Demo/turtle under Lib/
Raymond Hettinger added the comment: > I think it a mistake that tkinter.__init__ is huge, > about as big as the other 13 modules added together. > It makes it really hard to dive into the code That is certainly *not* a best practice. -- nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue10199> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Raymond Hettinger added the comment: I agree with the OP's request. d.pop(k) is conceptually equivalent to: r = d[k]# raises KeyError(k) del d[k] return r The current message was probably borrowed from dict.popitem(). But that is much different since the dict.pop(k) method is key-specific (instead of size related). This fix should be backported (as it doesn't change guaranteed behaviors but does improve the debugability). -- assignee: -> rhettinger stage: -> needs patch versions: +Python 2.7, Python 3.1 ___ Python tracker <http://bugs.python.org/issue10221> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Changes by Raymond Hettinger : -- priority: normal -> low ___ Python tracker <http://bugs.python.org/issue10221> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Changes by Raymond Hettinger : -- resolution: accepted -> stage: commit review -> patch review ___ Python tracker <http://bugs.python.org/issue10221> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6105] json.dumps doesn't respect OrderedDict's iteration order
Changes by Raymond Hettinger : -- priority: normal -> high ___ Python tracker <http://bugs.python.org/issue6105> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10242] unittest's assertItemsEqual() method makes too many assumptions about its input
New submission from Raymond Hettinger : class T(unittest.TestCase): def test_items_equal(self): # this test fails, but should succeed a = [{2,4}, {1,2}] b = a[::-1] self.assertItemsEqual(a, b) This method has a fast-path using sorted() and a slow-path that doesn't care about cross-type comparisons. The fast-path is incorrect though and gets the wrong answer in the above test case. -- assignee: michael.foord messages: 119960 nosy: michael.foord, rhettinger priority: high severity: normal status: open title: unittest's assertItemsEqual() method makes too many assumptions about its input versions: Python 2.7, Python 3.2 ___ Python tracker <http://bugs.python.org/issue10242> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10240] dict.update.__doc__ is misleading
Raymond Hettinger added the comment: I'm not sure that we should mention the fast path for dicts. That is an implementation detail and may not be present in IronPython, PyPy, Jython, etc. The current version includes: D.updated(E, **F) --> None. Updated D for dict/iterable E and F. ISTM that covers the semantics of what it does. Your proposed modification gets into how it does it. -- nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue10240> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6105] json.dumps doesn't respect OrderedDict's iteration order
Raymond Hettinger added the comment: Backported to 2.7 See r85966 -- resolution: -> fixed status: open -> closed ___ Python tracker <http://bugs.python.org/issue6105> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Raymond Hettinger added the comment: See r85967, r85968 and r85969. -- resolution: -> fixed status: open -> closed ___ Python tracker <http://bugs.python.org/issue10221> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10164] Add an assertBytesEqual to unittest and use it for bytes assertEqual
Changes by Raymond Hettinger : -- assignee: -> rhettinger nosy: +rhettinger priority: normal -> low ___ Python tracker <http://bugs.python.org/issue10164> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10164] Add an assertBytesEqual to unittest and use it for bytes assertEqual
Raymond Hettinger added the comment: Am discussing this with the OP on IRC and tabling it for a while so we can better think out the API. The goal is to let assertEqual(a, b) do straight-comparions of raw bytes, but to give a nice looking diff (possibly translated with line breaks or somesuch) when the test fails. This will be helpful in testing the email module. The current patch requires that assertBytesEqual be exposed and called directly so that a user can specify a split-at argument. The purpose of that argument is to approximate the line breaking that occurs naturally in text. The OP does not want to decode the bytes prior to the equality test, but does want a readable diff whenever the bytes represent ascii text. -- resolution: -> later ___ Python tracker <http://bugs.python.org/issue10164> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10160] operator.attrgetter slower than lambda after adding dotted names ability
Raymond Hettinger added the comment: The patch looks fine. You're overview of the process presented here in the tracker would make a nice comment in the code. If Antoine is happy with the latest patch, then it's ready to apply. -- assignee: rhettinger -> pitrou ___ Python tracker <http://bugs.python.org/issue10160> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5729] Allows tabs for indenting JSON output
Raymond Hettinger added the comment: Updated and applied in r86022. -- resolution: -> accepted status: open -> closed ___ Python tracker <http://bugs.python.org/issue5729> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10260] Add a threading.Condition.wait_for() method
Changes by Raymond Hettinger : -- title: Add a thrading.Condition.wait_for() method -> Add a threading.Condition.wait_for() method ___ Python tracker <http://bugs.python.org/issue10260> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9974] tokenizer.untokenize not invariant with line continuations
Raymond Hettinger added the comment: > My patch handles the described situation, albeit a bit poorly ... Let us know when you've got a cleaned-up patch and have run the round-trip tests on a broad selection of files. For your test case, don't feel compelled to use doctest. It's okay to write a regular unittest and add that to the test suite. -- assignee: rhettinger -> priority: normal -> low ___ Python tracker <http://bugs.python.org/issue9974> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9685] tuples should remember their hash value
Changes by Raymond Hettinger : -- assignee: rhettinger -> ___ Python tracker <http://bugs.python.org/issue9685> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10110] Queue doesn't recognize it is full after shrinking maxsize
Raymond Hettinger added the comment: Applied in r86049. -- resolution: -> fixed status: open -> closed ___ Python tracker <http://bugs.python.org/issue10110> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10025] random.seed not initialized as advertised
Raymond Hettinger added the comment: Removed the inaccurate description. See r86053. -- resolution: -> fixed status: open -> closed ___ Python tracker <http://bugs.python.org/issue10025> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7447] Sum() doc and behavior mismatch
Raymond Hettinger added the comment: Fixed in r86066, r86068 and r86069. -- resolution: -> fixed status: open -> closed versions: -Python 2.6 ___ Python tracker <http://bugs.python.org/issue7447> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7402] Improve reduce example in doanddont.rst
Raymond Hettinger added the comment: Fixed in r86070, r86071, and r86072. -- ___ Python tracker <http://bugs.python.org/issue7402> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7402] Improve reduce example in doanddont.rst
Changes by Raymond Hettinger : -- resolution: -> fixed status: open -> closed ___ Python tracker <http://bugs.python.org/issue7402> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9886] Make operator.itemgetter/attrgetter/methodcaller easier to discover
Raymond Hettinger added the comment: Fixed. See r86073. -- resolution: -> fixed status: open -> closed ___ Python tracker <http://bugs.python.org/issue9886> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9120] Reduce pickle size for an empty set
Raymond Hettinger added the comment: Have looked at this again and think I don't care what happens to it. The gain is minimal but it doesn't take much extra core. Like Fred, I'm not sure having another code path to test and maintain just to save 5 bytes. Unassigning. If anyone except the OP feels strongly either way, either close it or apply it. -- assignee: rhettinger -> type: feature request -> performance ___ Python tracker <http://bugs.python.org/issue9120> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10242] unittest's assertItemsEqual() method makes too many assumptions about its input
Raymond Hettinger added the comment: I'll fix this in 2.7. For 3.2, may remove the method entirely (for the reasons discussed on python-dev). -- assignee: michael.foord -> rhettinger ___ Python tracker <http://bugs.python.org/issue10242> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10273] Clean-up Unittest API
New submission from Raymond Hettinger : * Dedocument assertSetEqual, assertDictEqual, assertListEqual, and assertTupleEqual. These are all automatically dispatched from assertEqual. The user need not call any of these directly. These methods should not have been exposed in the docs. * Add new names and dedocument old names for assertLess, assertLessEqual, assertGreater, assertGreaterEqual. The new names are modeled after the gt, le, lt convention used elsewhere in the language. This avoids to problems remembering the current spelling quirks (dropping the Than in LessEqual, pluralization, camel casing, being too long, etc). New names will be assertLE, assertLT, assertGE, and assertGT. * Add news names and dedocument assertRegexpMatches and assertNotRegexpMatches. These names haves have multiple issues (they actually do a re.search not a re.match, they are long, the pluralization is inconsistent with the assertEqual convention, they don't agree with the names used in other unittest implementations such as PHPunit and Junit). The new names will be assertRegexp and assertNotRegexp. * Remove the assertItemsEqual method (which is new in 3.2). Its semantics are not obvious from its name (i.e. duplicates matter, order does not matter, expects elements not items, has O(n**2) behavior after an impending bug fix, uses on equality for matching not hashing or ordering). In most common cases, it is more explicit and flexible to use assertEqual after casting to a set, a list, or sorted list. Also note that other unittest implementations such as PHPunit and JUnit do not have this method. See http://mail.python.org/pipermail/python-dev/2010-October/105073.html * Recombine the package into a single file. See http://mail.python.org/pipermail/python-dev/2010-October/105025.html and http://mail.python.org/pipermail/python-dev/2010-October/104887.html * We need to review the camel cased spelling on two methods that are new in 3.2. Should it be assertIsinstance or assertIsInstance? assert -- assignee: rhettinger messages: 120100 nosy: rhettinger priority: normal severity: normal status: open title: Clean-up Unittest API versions: Python 3.2 ___ Python tracker <http://bugs.python.org/issue10273> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10221] {}.pop('a') raises non-standard KeyError exception
Raymond Hettinger added the comment: We don't usually test the content of error messages because they are not a guaranteed behavior. -- ___ Python tracker <http://bugs.python.org/issue10221> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10273] Clean-up Unittest API
Raymond Hettinger added the comment: [Antoine] > I would prefer assertRegex to assertRegexp That makes sense. It is the name used in other unittest implementations, it matches what the re module used to be called in Python, and it avoids issues with camel casing (i.e. Regexp vs RegExp). -- ___ Python tracker <http://bugs.python.org/issue10273> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10273] Clean-up Unittest API
Changes by Raymond Hettinger : -- assignee: michael.foord -> rhettinger ___ Python tracker <http://bugs.python.org/issue10273> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10038] json.loads() on str should return unicode, not str
Raymond Hettinger added the comment: To mitigate possible negative impacts from changing the return type, consider adding a parse_string hook that lets users control the return type: json.loads(f, parse_int=decimal.Decimal, parse_string=repr) -- nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue10038> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8488] Docstrings of non-data descriptors "ignored"
Changes by Raymond Hettinger : -- priority: normal -> low ___ Python tracker <http://bugs.python.org/issue8488> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10273] Clean-up Unittest API
Raymond Hettinger added the comment: After discussion on python-dev, it seems that API lock-in precludes any change to the package structure. So, the main proposals left are the addition of new better aliases for some of the functions and changing to the docs so that the new name is clear: assertLE(self, other) old name: AssertLessEqual . . . Also, I we should still dedocument assertEqual and its brethren and leave assertEqual as the primary interface. At some point, we could add an option to assertEqual to allow user control of how failing results are displayed. This would let us separate content from presentation (i.e. a==b vs how a diff would get presented). -- ___ Python tracker <http://bugs.python.org/issue10273> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10281] Exception raised when an NNTP overview field is absent
Raymond Hettinger added the comment: Besides being shorter, the advantages of assertLE are consistent with the rich comparison method names, no worries about Than, no camel casing ambiguities, no pluralization or other nmemonic issues (LessThanEqual or LessThanEquals or LessThanOrEqual or LessThanOrEqualTo). The goal is to make sure you don't have to look up the spelling every time you use them. That being said, assertEqual can't change. It has been around forever and is clear about what it does. What I am sure about is that assertLess and assertLessEqual are very non-standard spellings and that infrequent users of comparison assertions won't remember them. -- nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue10281> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10273] Clean-up Unittest API
Raymond Hettinger added the comment: Besides being shorter, the advantages of assertLE are consistent with the rich comparison method names, no worries about Than, no camel casing ambiguities, no pluralization or other nmemonic issues (LessThanEqual or LessThanEquals or LessThanOrEqual or LessThanOrEqualTo). The goal is to make sure you don't have to look up the spelling every time you use them. That being said, assertEqual can't change. It has been around forever and is clear about what it does. What I am sure about is that assertLess and assertLessEqual are very non-standard spellings and that infrequent users of comparison assertions won't remember them. -- ___ Python tracker <http://bugs.python.org/issue10273> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10281] Exception raised when an NNTP overview field is absent
Changes by Raymond Hettinger : -- Removed message: http://bugs.python.org/msg120300 ___ Python tracker <http://bugs.python.org/issue10281> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10242] unittest's assertItemsEqual() method makes too many assumptions about its input
Raymond Hettinger added the comment: Suggestions: * new name: assertCountEqual(a, b) or:assertElementCountEqual(a, b) this name captures the essential service: - unordered comparison where duplicates matter - inputs are "elements", not "items" which means key/value pairs * O(n) implementation with O(n**2) fallback: try: a_cnt = collections.Counter(a) b_cnt = collections.Counter(b) except TypeError: # do current O(n**2) fallback else: if a_cnt == b_cnt: # test passed else: in_a_but_not_in_b = a - b in_b_but_not_in_a = b - a # display nice diff * documentation should emphasize the new name: assertElementCountEqual(a, b) obsolete alias: assertItemsEqual(a, b) -- assignee: rhettinger -> michael.foord ___ Python tracker <http://bugs.python.org/issue10242> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10242] unittest's assertItemsEqual() method makes too many assumptions about its input
Raymond Hettinger added the comment: > I'd be inclined to insert a check that falls back > to the "unorderable_list_difference" approach in > the case where "expected != sorted(reversed(expected))". Too fragile and subtle. The method need to be absolutely straight-forward. -- ___ Python tracker <http://bugs.python.org/issue10242> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10273] Clean-up Unittest API
Raymond Hettinger added the comment: > For the regexp methods we should use assertRegexp assertRegex is better. it matches the name used in other unittest implementations, there is not confusion with camel casing RegExp vs Regexp, and it matches the former name of Python's own regex module. > We should leave the gt / le / lt methods as they are. The assertLessEqual name is non-standard, it will never be spelled right by someone who hasn't used it recently. > The documentation can be improved by moving *all* the deprecated > methods (new and old) out of the main documentation and > into a separate section at the end of the documentation See issue 10242 for a suggestion on how to handle renaming (document the new and old name in the same entry, noting that one name is old). >> For assertItemsEqual Raymond suggests assertElementCountsEqual. > Why replace a long awkward name with an even longer > and more awkward name? If length is an issue, assertCountsEqual will also do fine. The important virtue is clarity. The problem with ItemsEqual is that it doesn't tell you anything about what it does (unordered comparison where duplicates matter). Also, the term "items" in Python usually means key/value pairs. That is why we use the term "elements" in sets, itertools, etc. In contrast, assertCountsEqual tells you what it does, compares the element counts. It is the same as Counter(a)==Counter(b) for hashable elements and an equivalent for unhashable elements. -- ___ Python tracker <http://bugs.python.org/issue10273> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10273] Clean-up Unittest API
Raymond Hettinger added the comment: > assertLess, on the other hand, I often get wrong, > since it is *not* __lt__ spelled out. Right. Even Michael gets that one wrong. Meditate on why Guido created the special method __lt__ instead of __less_than__. Regardless of why Guido made that choice, we do already have a standard way to spell less-than in Python, and it would be good to stick with it. -- ___ Python tracker <http://bugs.python.org/issue10273> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10242] unittest's assertItemsEqual() method makes too many assumptions about its input
Raymond Hettinger added the comment: One nuance, it may be better to implement as: a_cnt = collections.Counter(iter(a)) b_cnt = collections.Counter(iter(b)) That will bypass the special handling the Counter constructor has if the argument is a Mapping. -- ___ Python tracker <http://bugs.python.org/issue10242> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10314] Improve JSON encoding with sort_keys=True
Raymond Hettinger added the comment: +1 -- nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue10314> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10302] Add class-functions to hash many small objects with hashlib
Raymond Hettinger added the comment: I concur with Overlord Antoine ;-) The API of "hashfunc *files" looks like something that should be done at the command line in bash. For the most part, I think users are better-off using normal Python loops so they can do something with the computed hashes as the files are read. -- nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue10302> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10317] Add TurtleShell to turtle
Raymond Hettinger added the comment: It's better as a demo for cmd than as a useful utility for the turtle module. Also, we want people using turtle to learn Python, not to bypass the language altogether. -- assignee: -> rhettinger resolution: -> rejected status: open -> closed ___ Python tracker <http://bugs.python.org/issue10317> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10323] Final state of underlying sequence in islice
Changes by Raymond Hettinger : -- assignee: -> rhettinger components: +Documentation -Interpreter Core priority: normal -> low versions: -Python 2.7, Python 3.1 ___ Python tracker <http://bugs.python.org/issue10323> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1346238] A constant folding optimization pass for the AST
Raymond Hettinger added the comment: David, it would be great if an optional AST optimization pass could do something that we don't already have (perhaps, loop invariant code motion when python is called with -OO or somesuch). The AST tree makes it possible for the first time to provide some non-trivial optimizations, so aim high. -- ___ Python tracker <http://bugs.python.org/issue1346238> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10334] Add new reST directive for links to source code
New submission from Raymond Hettinger : In a few cases where the pure python source code is a helpful adjunct to the documentation, I've added some links using the "seealso" directive: .. seealso:: Latest version of the `ast module Python source code <http://svn.python.org/view/python/branches/release27-maint/Lib/ast.py?view=markup>`_ It would be great if a new directive could be introduced for this purpose. Something like: .. sourcecode Lib/ast.py With a directive, we could easily point the root directory to different releases or to a local source directory for local doc build. -- assignee: georg.brandl components: Documentation messages: 120587 nosy: georg.brandl, rhettinger priority: low severity: normal status: open title: Add new reST directive for links to source code type: feature request versions: Python 3.2 ___ Python tracker <http://bugs.python.org/issue10334> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10273] Clean-up Unittest API
Raymond Hettinger added the comment: > people who are used to the current spelling > will have to notice the change, note that one > name is now deprecated I haven't proposed any deprecations. Just add the new names as aliases. Change the docs list the new names as primary and mention the old name for reference. We don't have to sticking with crummy naming. -- ___ Python tracker <http://bugs.python.org/issue10273> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10357] ** and "mapping" are poorly defined in python docs
Changes by Raymond Hettinger : -- assignee: d...@python -> rhettinger ___ Python tracker <http://bugs.python.org/issue10357> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10356] decimal.py: hash of -1
Raymond Hettinger added the comment: Good catch Stefan. This is a regression from Py2.6. The behavior for decimal should match that for int. IDLE 2.6.2 >>> hash(-1) -2 >>> (-1).__hash__() -2 >>> from decimal import * >>> hash(Decimal(-1)) -2 >>> Decimal(-1).__hash__() -2 -- nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue10356> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10357] ** and "mapping" are poorly defined in python docs
Raymond Hettinger added the comment: > Even if the glossary pointed to collections.html, > there are far more methods specified there than > are needed to be **able. That is an implementation detail and is subject to change. If someone supplies an argument satisfying collections.Mapping, that should be sufficient across all implementations. > dict.update's doc string is explicit about what > it requires from the argument: Duck-typing is still allowed when explicit requirements have been exposed (we do this a lot with .readline() for example). For the most part though, we want to specify "needs a Mapping" in the sense of collections.Mapping. -- ___ Python tracker <http://bugs.python.org/issue10357> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10354] tempfile.template is broken
Raymond Hettinger added the comment: +1 for just deleting it. nothing is lost by deleting code that never worked in the first place ;-) -- nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue10354> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7061] Improve turtle module documentation
Raymond Hettinger added the comment: The mini change log is harmless. I would leave it as is. -- ___ Python tracker <http://bugs.python.org/issue7061> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9520] Add Patricia Trie high performance container
Changes by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker <http://bugs.python.org/issue9520> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10408] Denser dicts and linear probing
Raymond Hettinger added the comment: My previous experiments along these lines showed it was a dead-end. The number of probes was the most important factor and beat-out any effort to improve cache utilization from increased density. Doing extra work (more probes) in order to improve cache effects is very difficult because most real programs have an uneven access pattern so that the most frequently accesses items are usually already in cache. So, the attempted improvement only helps the less frequently accessed items and isn't worth the extra number of probes. Another result from earlier experiments is that benchmarking the experiment is laden with pitfalls. Tight timing loops don't mirror real world programs, nor do access patterns with uniform random distributions. -- ___ Python tracker <http://bugs.python.org/issue10408> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10408] Denser dicts and linear probing
Raymond Hettinger added the comment: FWIW, one way to make a dict denser without increasing the number of probes is to use Brent's Variation of Algorithm D in Knuth. That optimizes the insertion order to minimize the number of collisions and lets you pack well over two-thirds full without degradation. -- ___ Python tracker <http://bugs.python.org/issue10408> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10403] Use "member" consistently
Raymond Hettinger added the comment: > "Members and methods" should just be "attributes". +1 That substitution should be made almost everywhere. Individual slot variable are still called members though and their type is a member_descriptor. And the C API still has a tp_members entry. Otherwise, it looks like the term member is out-of-date. -- nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue10403> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10408] Denser dicts and linear probing
Raymond Hettinger added the comment: See Objects/dictnotes.txt for some of the results. I spent about full month trying to optimize dict performance either by tuning parameters or using different algorithms. There were a couple wins that were not implemented. 1) Allowing users to control insertion order or at least specify which keys are frequently accessed so that we could assure a first-time hit. 2) Allowing users to pre-size a dictionary so that resizes wouldn't be needed or an so they could control density. Guido didn't want to expose these controls. The PyPy guys published a paper on their results with alternative dict implementations and specialized dicts. You might want to look at that. IIRC, they found only minor wins. -- ___ Python tracker <http://bugs.python.org/issue10408> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10410] Is iterable a container type?
Changes by Raymond Hettinger : -- assignee: d...@python -> rhettinger nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue10410> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10410] Is iterable a container type?
Raymond Hettinger added the comment: > "iterable" is described as "A container object > capable of returning its members one at a time." That wording is confusing. I'll fix it. > Likewise, "and objects of any classes you define > with an __iter__() or __getitem__() method." is > wrong because __getitem__ method is not relate to > iterable That wording is correct. Sequences are automatically iterable even if they don't define __iter__. For example: >>> class A: ... def __getitem__(self, i): ... if i > 10: ... raise IndexError(i) ... return i * 100 >>> list(A()) [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000] If you're curious, the details are in the PyObject_GetIter() function in http://svn.python.org/view/python/branches/release27-maint/Objects/abstract.c?view=markup . -- priority: normal -> low ___ Python tracker <http://bugs.python.org/issue10410> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9520] Add Patricia Trie high performance container
Raymond Hettinger added the comment: I don't think a Patricia Trie is going to find its way into the code distribution. It has a better chance as a third-party module listed on PyPI (much in the same way that people access memcached from Python). -- resolution: -> rejected status: open -> closed ___ Python tracker <http://bugs.python.org/issue9520> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10410] Is iterable a container type?
Raymond Hettinger added the comment: Removed the incorrect "container" reference. See r86463. -- resolution: -> fixed status: open -> closed ___ Python tracker <http://bugs.python.org/issue10410> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11260] smtpd-as-a-script feature should be documented and should use argparse
Raymond Hettinger added the comment: > As I said, my only intention here is be to document > (and argparsify/formalize) what is already there. In a handful of cases, that would be useful; however, for the most part, these APIs were undocumented for a reason. Some of the command-line interfaces were slapped together without much of a design effort; some were little more than quick-and-dirty ad-hoc tests. It would be a mistake to "document and formalize" accidental mini-apps. There's no harm in adding --help or a usage example, but please avoid making behavior guarantees that we really don't want to have to live with. Only "document and formalize" the parts that are well thought out. -- ___ Python tracker <http://bugs.python.org/issue11260> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11297] Make ChainMap() public in the collections module.
New submission from Raymond Hettinger : Attaching a documentation patch. -- assignee: rhettinger files: chainmap.diff keywords: patch messages: 129161 nosy: rhettinger priority: low severity: normal status: open title: Make ChainMap() public in the collections module. type: feature request versions: Python 3.3 Added file: http://bugs.python.org/file20858/chainmap.diff ___ Python tracker <http://bugs.python.org/issue11297> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11297] Make ChainMap() public in the collections module.
Raymond Hettinger added the comment: FWIW, the new_child() and parents() part of the API was modeled after contexts in ANLTR where they are needed to overcome the limitations of Django's push/pop style which precludes a context from having multiple, independent children at the same time. The module docstring in the http://code.activestate.com/recipes/577434/ recipe shows how new_child() can be used to easily model both dynamic scoping and nested scoping. The other advantage of the new_child/parents API over the push/pop API is that it overcomes the occasional templating need to keep two copies of the context (before a push and after a push). In some ways, it is more difficult to keep track of a mutating chain that is being continuously pushed and popped. It is simpler to assign a chain to a variable and always know that it is associated with a given template and not have to worry about whether some utility function pushed a new context and failed to pop it when it was done. A push/pop style introduces the same problems as matching matching malloc() with free() in C. -- ___ Python tracker <http://bugs.python.org/issue11297> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11304] Input/output tutorial - PI is rounded not truncated
Changes by Raymond Hettinger : -- assignee: docs@python -> rhettinger nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue11304> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11304] Input/output tutorial - PI is rounded not truncated
Raymond Hettinger added the comment: Fixed in r88356, r88537, and r88538. Thanks for the report. -- resolution: -> fixed status: open -> closed ___ Python tracker <http://bugs.python.org/issue11304> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear() and list.copy()
Raymond Hettinger added the comment: The patch looks great. Please apply it. -- assignee: rhettinger -> eli.bendersky resolution: later -> accepted ___ Python tracker <http://bugs.python.org/issue10516> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear() and list.copy()
Raymond Hettinger added the comment: Eli doesn't need to post a new patch. I'm sure he will fix any nits in his commit. -- ___ Python tracker <http://bugs.python.org/issue10516> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear() and list.copy()
Raymond Hettinger added the comment: [Éric Araujo] > +"L.clear() -> None -- remove all items from L"); > It looks like other methods that return None > just omit the “-> type” part. These kind of nitty comments really aren't helpful. It consumes more time to talk about them than they're worth. In this case, Eli was modeling after the docstring in dictobject.c: PyDoc_STRVAR(clear__doc__, "D.clear() -> None. Remove all items from D."); Just because list.remove.__doc__ failed to consistently follow that convention doesn't make Eli's patch incorrect. -- ___ Python tracker <http://bugs.python.org/issue10516> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11296] Possible error in What's new in Python 3.2 : duplication of rsplit() mention
Raymond Hettinger added the comment: Okay fixed. The rsplit() method was mentioned in both underlying tracker issues, so it got mentioned twice when once would have been enough :-) -- assignee: docs@python -> rhettinger nosy: +rhettinger priority: normal -> low resolution: -> fixed status: open -> closed ___ Python tracker <http://bugs.python.org/issue11296> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear() and list.copy()
Raymond Hettinger added the comment: Unless someone raises a controversial and non-trivial issue about adding clear() and copy() to bytearray, there is no need for a python-dev discussion on the subject. Just post a patch to the tracker. -- ___ Python tracker <http://bugs.python.org/issue10516> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear() and list.copy()
Raymond Hettinger added the comment: Georg, what is the issue? Is there some reason that bytearrays should not be copied or cleared? Is there some reason to prefer the current: dup = b[:] # copy del b[:] # clear -- ___ Python tracker <http://bugs.python.org/issue10516> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear() and list.copy()
Raymond Hettinger added the comment: The ABCs are subset of the methods for the concrete APIs. We've avoided the likes of copy() because it requires knowledge of the constructor's signature -- for example, MutableMapping does not cover copy(). It is okay for Eli to add MutableSequence.clear() because it can be implemented in terms of pop(), much like we do for MutableMapping.clear(). Eli, feel free to create a patch to add clear() and copy() to bytearray and to add clear() to MutableSequence. Assign the patch to me for review. -- ___ Python tracker <http://bugs.python.org/issue10516> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11303] b'x'.decode('latin1') is much slower than b'x'.decode('latin-1')
Raymond Hettinger added the comment: What's wrong with Marc's commit? He's using the standard names. -- nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue11303> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11297] Make ChainMap() public in the collections module.
Raymond Hettinger added the comment: Antoine. Thanks. I put in a paragraph re-emphasizing that ChainMap is a view and that changes in the underlying mappings get reflected in the ChainMap. Also, the first sentence says that ChainMap groups multiple dicts or other mappings. So, any mapping-like object will work. Éric, I changed built-in to builtin. It is used as an adjetive, not as a module reference (that's the usual practice when referring the builtin functions). See r88628. -- resolution: -> fixed status: open -> closed ___ Python tracker <http://bugs.python.org/issue11297> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11297] Make ChainMap() public in the collections module.
Raymond Hettinger added the comment: I was thinking of adding a recipes section to show how to extend or override the class: class DjangoContext(ChainMap): def push(self): self.maps.insert(0, {}) def pop(self): self.maps.pop(0) class NestedScope(ChainMap): 'Mutating methods that write to first matching dict' def __setitem__(self, key, value): '''Find the first matching *key* in chain and set its value. If not found, sets in maps[0]. ''' for m in self.maps: if key in m: break else: m = self.maps[0] try: cs = m.chain_set except AttributeError: m[key] = value else: cs(key, value) def __delitem__(self, key): '''Find and delete the first matching *key* in the chain. Raise KeyError if not found. ''' for m in self.maps: if key in m: break try: cd = m.chain_del except AttributeError: del m[key] else: cd(key) def popitem(self): for m in self.maps: if m: break return m.popitem() def clear(self): for m in self.maps: m.clear() -- ___ Python tracker <http://bugs.python.org/issue11297> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11303] b'x'.decode('latin1') is much slower than b'x'.decode('latin-1')
Raymond Hettinger added the comment: > If you agree, Raymond, I'll backport the patch. Yes. That will address Antoine's legitimate concern about making other backports harder, and it will get all the Python's to use the canonical spelling. For other spellings like "utf8" or "latin1", I wonder if it would be useful to emit a warning/suggestion to use the standard spelling. -- ___ Python tracker <http://bugs.python.org/issue11303> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11333] Add empty __slots__ to collections.abc abstract base classes
Raymond Hettinger added the comment: Guido? -- assignee: -> gvanrossum nosy: +gvanrossum ___ Python tracker <http://bugs.python.org/issue11333> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11339] annotation for class being defined
Raymond Hettinger added the comment: This would be an important fix-up if we could find some way to implement it. The basic problem is that the class object is defined after the class definitions have been made, so the target of the Graph reference isn't known when the method definitions are being compiled. One approach to solving this problem is to use a deferred/resolved pattern (creating a valid reference to Graph that is visible during method compilation, but gets filled-in with the other methods afterwards). I haven't thought this through completely but think it could be done if we let the compiler write to the class dictionary (this is normally off-limits and protected by a dict_proxy). If we let the system punch a hole in the proxy, it is possible to resolve deferred class definitions. Here's a concept sketch: class Prepared(type): 'Preload the class with a reference to itself' @classmethod def __prepare__(mcl, name, bases): return {name: type(name, bases, {})} def __new__(mcl, name, bases, mapping): global deferred_class tmpcls = super().__new__(mcl, name, bases, mapping) deferred_class = mapping[name] deferred_class.__dict__.update(tmpcls.__dict__) # XXX need writeable dict_proxy return deferred_class class Graph(metaclass=Prepared): def reverse(self) -> Graph: ... -- nosy: +arigo, rhettinger, stutzbach resolution: rejected -> status: closed -> open ___ Python tracker <http://bugs.python.org/issue11339> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11339] annotation for class being defined
Changes by Raymond Hettinger : -- Removed message: http://bugs.python.org/msg129656 ___ Python tracker <http://bugs.python.org/issue11339> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11339] annotation for class being defined
Raymond Hettinger added the comment: This would be an important fix-up if we could find some way to implement it. The basic problem is that the class object is defined after the class definitions have been made, so the target of the Graph reference isn't known when the method definitions are being compiled. One approach to solving this problem is to use a deferred/resolved pattern (creating a valid reference to Graph that is visible during method compilation, but gets filled-in with the other methods afterwards). I haven't thought this through completely but think it could be done if we let the compiler write to the class dictionary (this is normally off-limits and protected by a dict_proxy). If we let the system punch a hole in the proxy, it is possible to resolve deferred class definitions. Here's a concept sketch: class Prepared(type): 'Preload the class with a reference to itself' @classmethod def __prepare__(mcl, name, bases): return {name: type(name, bases, {})} def __new__(mcl, name, bases, mapping): tmpcls = super().__new__(mcl, name, bases, mapping) deferred_class = mapping[name] deferred_class.__dict__.update(tmpcls.__dict__) # XXX need writeable dict_proxy return deferred_class class Graph(metaclass=Prepared): -- ___ Python tracker <http://bugs.python.org/issue11339> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11339] annotation for class being defined
Changes by Raymond Hettinger : -- Removed message: http://bugs.python.org/msg129657 ___ Python tracker <http://bugs.python.org/issue11339> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11339] annotation for class being defined
Raymond Hettinger added the comment: class Prepared(type): 'Preload the class with a reference to itself' @classmethod def __prepare__(mcl, name, bases): return {name: type(name, bases, {})} def __new__(mcl, name, bases, mapping): tmpcls = super().__new__(mcl, name, bases, mapping) deferred_class = mapping[name] deferred_class.__dict__.update(tmpcls.__dict__) # XXX need writeable dict_proxy return deferred_class class Graph(metaclass=Prepared): def reverse(self) -> Graph: ... -- ___ Python tracker <http://bugs.python.org/issue11339> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11339] annotation for class being defined
Changes by Raymond Hettinger : -- Removed message: http://bugs.python.org/msg129659 ___ Python tracker <http://bugs.python.org/issue11339> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11339] annotation for class being defined
Raymond Hettinger added the comment: This would be an important fix-up if we could find some way to implement it. The basic problem is that the class object is defined after the class definitions have been made, so the target of the Graph reference isn't known when the method definitions are being compiled. One approach to solving this problem is to use a deferred/resolved pattern (creating a valid reference to Graph that is visible during method compilation, but gets filled-in with the other methods afterwards). I haven't thought this through completely but think it could be done if we let the compiler write to the class dictionary (this is normally off-limits and protected by a dict_proxy). If we let the system punch a hole in the proxy, it is possible to resolve deferred class definitions. class Prepared(type): 'Preload the class with a reference to itself' @classmethod def __prepare__(mcl, name, bases): return {name: type(name, bases, {})} def __new__(mcl, name, bases, mapping): tmpcls = super().__new__(mcl, name, bases, mapping) deferred_class = mapping[name] deferred_class.__dict__.update(tmpcls.__dict__) # XXX need writeable dict_proxy return deferred_class class Graph(metaclass=Prepared): def reverse(self) -> Graph: ... -- ___ Python tracker <http://bugs.python.org/issue11339> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com