Roundup Robot added the comment:
New changeset 4b3238923b01 by Raymond Hettinger in branch 'default':
Issue #16694: Add source code link for operator.py
http://hg.python.org/cpython/rev/4b3238923b01
--
___
Python tracker rep...@bugs.python.org
Roundup Robot added the comment:
New changeset 97834382c6cc by Antoine Pitrou in branch 'default':
Issue #16694: Add a pure Python implementation of the operator module.
http://hg.python.org/cpython/rev/97834382c6cc
--
nosy: +python-dev
___
Python
Antoine Pitrou added the comment:
I've now commited the latest patch. Thank you very much, Zachary!
--
resolution: - fixed
stage: commit review - committed/rejected
status: open - closed
___
Python tracker rep...@bugs.python.org
Antoine Pitrou added the comment:
length_hint() looks ok as well.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
___
Python-bugs-list
Raymond Hettinger added the comment:
I reviewed the attrgetter(), mathodgetter(), and itemgetter() code in
py_operator.v12.diff. The looks clean and correct.
--
assignee: rhettinger -
___
Python tracker rep...@bugs.python.org
Serhiy Storchaka added the comment:
Now we can remove all __func__s from _operator.c.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Zachary Ware added the comment:
Thank you for the review, Raymond.
Since Serhiy agrees that the _operator __func__s are unnecessary, here's a v13
that removes them. Again, I'm not a native C speaker, so these new changes in
_operator.c deserve a bit of extra scrutiny. Everything builds and
Zachary Ware added the comment:
Here's another new version of the patch, addressing Ezio's review comments and
a few things I found after giving operator.py a closer look myself.
Things changed in operator.py in this version:
- all ``__func__ = func`` assignments are moved to the end, after
Changes by Zachary Ware zachary.w...@gmail.com:
--
nosy: -Arfrever, brett.cannon, eric.araujo, ezio.melotti, jcea, meador.inge,
pitrou, serhiy.storchaka, zach.ware
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
Changes by Zachary Ware zachary.w...@gmail.com:
Removed file: http://bugs.python.org/file28327/operator.py
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Changes by Zachary Ware zachary.w...@gmail.com:
Removed file: http://bugs.python.org/file28328/py_operator.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Changes by Zachary Ware zachary.w...@gmail.com:
Removed file: http://bugs.python.org/file28374/py_operator.v3.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Changes by Zachary Ware zachary.w...@gmail.com:
Removed file: http://bugs.python.org/file28388/py_operator.v5.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Changes by Zachary Ware zachary.w...@gmail.com:
Removed file: http://bugs.python.org/file28383/py_operator.v4.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Changes by Zachary Ware zachary.w...@gmail.com:
Removed file: http://bugs.python.org/file28522/py_operator.v7.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Changes by Zachary Ware zachary.w...@gmail.com:
Removed file: http://bugs.python.org/file28524/py_operator.v8.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Changes by Zachary Ware zachary.w...@gmail.com:
Removed file: http://bugs.python.org/file28532/py_operator.v9.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Changes by Zachary Ware zachary.w...@gmail.com:
--
nosy: +Arfrever, brett.cannon, eric.araujo, ezio.melotti, jcea, meador.inge,
pitrou, serhiy.storchaka, zach.ware
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
Zachary Ware added the comment:
A change that I mentioned in a Rietveld comment on v10, but not in my last
message: __all__ in operator.py no longer includes all of the __func__s, as
currently doing from operator import * does not import all of the __func__s.
--
Serhiy Storchaka added the comment:
I think Antoine is more appropriate for committing this patch. I waited so long
with this because I do not dare to take responsibility for themselves (it's
almost like adding a new module).
--
assignee: serhiy.storchaka -
Raymond Hettinger added the comment:
I would like to spend some time with this before it goes forward (especially
the attrgetter, itemgetter, methodgetter group).
Right now, it looks like a nice effort but I don't see how it makes Python any
better for adding it. The odds are that this code
R. David Murray added the comment:
Raymond: it's not for the benefit of CPython.
--
nosy: +r.david.murray
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Raymond Hettinger added the comment:
[David]
Raymond: it's not for the benefit of CPython.
IIRC, all the other implementations of Python already have this code passing
tests, so it isn't really for their benefit either.
--
___
Python tracker
Alex Gaynor added the comment:
If a pure python operator module were a part of the stdlib, we (PyPy) would
probably delete most (if not all) of our own operator module.
--
nosy: +alex
___
Python tracker rep...@bugs.python.org
Antoine Pitrou added the comment:
Thank you!
One optional thing, the code churn could be minimized in test_operator.py by
writing operator = self.module at the beginning of each test method.
Otherwise, looks good to me.
--
___
Python tracker
Antoine Pitrou added the comment:
Zachary, I suppose Modules/_operator.c is a rename of Modules/operator.c.
Could you generate your patch using hg diff --git so that history isn't lost
here?
See also http://docs.python.org/devguide/committing.html#minimal-configuration
--
nosy:
Zachary Ware added the comment:
Zachary, I suppose Modules/_operator.c is a rename of Modules/operator.c.
Could you generate your patch using hg diff --git so that history isn't
lost here?
Of course; I thought I already had, but apparently I messed that up a bit. v11
is in the proper
Zachary Ware added the comment:
Since the older Windows project files were removed, v10 removes the patches to
them.
Everything else still applies cleanly.
Also, in the spirit of what Brett said in 16651 about not re-implementing
blindly, I did just look up what Jython, IronPython, and PyPy
Serhiy Storchaka added the comment:
v8 LGTM (except some trailing whitespaces).
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
___
Zachary Ware added the comment:
Note to self: learn to run patchcheck.py before posting. Whitespace issues
fixed in v9.
--
Added file: http://bugs.python.org/file28532/py_operator.v9.diff
___
Python tracker rep...@bugs.python.org
Serhiy Storchaka added the comment:
If no one objects I will commit this next week.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
___
Zachary Ware added the comment:
Sorry, I misunderstood Éric's suggestions regarding the tests; v6 is useless.
v7 forthcoming.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Changes by Zachary Ware zachary.w...@gmail.com:
Removed file: http://bugs.python.org/file28391/py_operator.v6.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Zachary Ware added the comment:
Ok, I believe the attached v7 properly addresses Éric's concerns about test
discovery, and has no other changes unrelated to that compared to v5.
Thank you very much to Ezio for directing me towards the json tests for an
example to work from.
--
nosy:
Changes by Zachary Ware zachary.w...@gmail.com:
Added file: http://bugs.python.org/file28524/py_operator.v8.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Changes by Serhiy Storchaka storch...@gmail.com:
--
assignee: - serhiy.storchaka
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
___
Changes by Meador Inge mead...@gmail.com:
--
nosy: +meador.inge
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
___
Python-bugs-list
Serhiy Storchaka added the comment:
I don't understand what is difference between v5 and v6.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Serhiy Storchaka added the comment:
About length_hint():
I were mean something like (even explicit getattr() not needed):
try:
hint = type(obj).__length_hint__
except AttributeError:
return default
try:
val = hint(obj)
except TypeError:
return default
...
This is a little
Changes by Éric Araujo mer...@netwok.org:
--
nosy: +eric.araujo
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
___
Python-bugs-list
Zachary Ware added the comment:
Here's another new version. Changes include:
- Address Serhiy's Rietveld comments
- Fix length_hint() the way it was meant to be fixed last time.
- Remove __getitem__ check on 'b' in concat and iconcat. More notes on this
below.
- Fix methodcaller as Serhiy
Serhiy Storchaka added the comment:
Good work, Zachary. I have no more nitpicks for you. ;)
LGTM.
--
stage: patch review - commit review
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
Serhiy Storchaka added the comment:
One comment to a committer. Don't forget to run `hg rename Modules/operator.c
Modules/_operator.c` before applying the patch.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
Zachary Ware added the comment:
Nits are no fun; thank you for picking them, Serhiy ;)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Éric Araujo added the comment:
FYI Mercurial can use the extended diff format invented by git, which supports
renames, changes to file permissions, etc.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
Éric Araujo added the comment:
The base test class should not inherit from TestCase: it will be picked up by
test discovery and then will break, as self.module will be None.
Typical usage:
class OperatorTestsMixin:
module = None
class COperatorTests(OperatorTestsMixin,
Zachary Ware added the comment:
Did not know that about test discovery, thank you Éric. Fixed in v6.
A few other test modules may need the same fix; I based my changes to
Lib/test/test_operator.py on Lib/test/test_heapq.py which has the same issue.
I'll open a new report for it and any
Serhiy Storchaka added the comment:
Sorry, I forgot push a Publish All My Drafts button. Please consider other my
comments to first patch. I also have added new comments about length_hint().
Your implementation of attrgetter() looks good. One possible disadvantage of
pure functional approach
Zachary Ware added the comment:
Here's v4, addressing Serhiy's comments on Reitveld.
--
Added file: http://bugs.python.org/file28383/py_operator.v4.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
Zachary Ware added the comment:
Sorry to have disappeared on this, other things took priority...
Thank you for the comments, Serhiy. v2 of the patch renames Modules/operator.c
to Modules/_operator.c, and changes that name every place I could find it.
I also tried to tidy up some of the error
Zachary Ware added the comment:
Considering what a huge headache it was to get my own patch to apply at home on
Linux rather than at work on Windows, here's a new version of the patch that
straightens out the line ending nightmare present in v2. No other changes made.
--
Added file:
Changes by Zachary Ware zachary.w...@gmail.com:
Removed file: http://bugs.python.org/file28373/py_operator.v2.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
Changes by Jesús Cea Avión j...@jcea.es:
--
nosy: +jcea
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
___
Python-bugs-list mailing list
Changes by Serhiy Storchaka storch...@gmail.com:
--
stage: - patch review
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
___
Serhiy Storchaka added the comment:
Here is a functional (and more effective) equivalent of attrgetter:
def attrgetter(attr, *attrs):
Return a callable object that fetches the given attribute(s) from its
operand.
After f=attrgetter('name'), the call f(r) returns r.name.
After
Serhiy Storchaka added the comment:
Perhaps Modules/operator.c should be renamed to Modules/_operator.c.
Also note, that error messages in Python an C implementations sometimes differ.
--
___
Python tracker rep...@bugs.python.org
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:
--
nosy: +Arfrever
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
New submission from Zachary Ware:
(Brett, I've made you nosy due to the relation to Issue16651.)
Here is a pure Python implementation of the operator module, or at least a
first draft thereof :). I'm attaching the module itself, as well as a patch to
integrate it.
Any and all review is
Changes by Zachary Ware zachary.w...@gmail.com:
--
keywords: +patch
Added file: http://bugs.python.org/file28328/py_operator.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16694
___
59 matches
Mail list logo