Message266530
Attached patch turns the Python implementation of functools.partial into a class. The implementation is as close to the C version as possible, except __repr__ where I went for a different, more Pythonic approach (output is identical).
I haven't yet added tests for this, and I had to fix something (because some errors occur if _functools is not present and that's the only way I know to make the tests run against the Python implementation). One test fails with the patch (and sys.modules["_functools"] = None):
...........................................................E....................
....................................................................
======================================================================
ERROR: test_pickle (test.test_functools.TestPartialC)
----------------------------------------------------------------------
Traceback (most recent call last):
File "E:\GitHub\cpython\lib\test\test_functools.py", line 224, in test_pickle
f_copy = pickle.loads(pickle.dumps(f, proto))
_pickle.PicklingError: Can't pickle <class 'functools.partial'>: it's not the sa
me object as functools.partial
----------------------------------------------------------------------
Ran 148 tests in 0.216s
FAILED (errors=1)
I'll try to see what kind of tests I can add to this to reliably test both 'partial' implementations. I'll also see what I can do about that one failing test. Oddly enough, there seems to be a test for subclassing '_functools.partial', which I might extend.
Raymond, what do you think? |
|
Date |
User |
Action |
Args |
2016-05-28 03:19:54 | abarry | set | recipients:
+ abarry, rhettinger, ncoghlan, vstinner, xiang.zhang |
2016-05-28 03:19:54 | abarry | set | messageid: <1464405594.78.0.630294477297.issue27137@psf.upfronthosting.co.za> |
2016-05-28 03:19:54 | abarry | link | issue27137 messages |
2016-05-28 03:19:54 | abarry | create | |
|