[issue8191] Make arg0 required argument in os.execl* functions

2010-04-19 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Mon, Apr 19, 2010 at 11:03 PM, R. David Murray wrote: > > Alexander, do you think it would be worthwhile to write up a summary of all > the issues > involved in these three releated bugs and post it to python-dev? Sure. I ranted abo

[issue8469] struct - please make sizes explicit

2010-04-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: It is very easy to generate the size table programmatically: >>> for c in "xcbB?hHiIlLqQfdspP": ... print(c, struct.calcsize(c)) ... x 1 c 1 b 1 B 1 ? 1 h 2 H 2 i 4 I 4 l 8 L 8 q 8 Q 8 f 4 d 8 s 1 p 1 P 8 However, all values abo

[issue7150] datetime operations spanning MINYEAR give bad results

2010-04-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: My patch includes unit tests and I tested it on Mac OS X. Anand, what kind of testing do you have in mind? -- versions: +Python 2.7, Python 3.2, Python 3.3 ___ Python tracker <http://bugs.python.

[issue8469] struct - please make sizes explicit

2010-04-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Tue, Apr 20, 2010 at 10:30 AM, Mark Dickinson wrote: .. > It would be possible to add the 'standard' sizes to that table (i.e. the > sizes that you get when using '<', '>', etc.);  would that be helpful? T

[issue1083] Confusing error message when dividing timedelta using /

2010-04-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: This is certainly not a bug, so I don't think targeting 2.7 is appropriate. I have explained in a comment on issue2706 (see msg75917) why I believe true division of timedelta by int should not be supported. In short, true division of timedelta b

[issue1100942] Add datetime.time.strptime and datetime.date.strptime

2010-04-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am +1 for adding these features and I have only one comment on the code: It is documented in time.strptime() documentation that """ The default values used to fill in any missing data when more accurate values cannot be inferred are (1

[issue1100942] Add datetime.time.strptime and datetime.date.strptime

2010-04-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: BTW, it does not bother me that "date.strptime() seems a bit odd, given that it cannot accept a time part." To me "time" in strptime means time specification that may include date, time or even just month. If parsed specification

[issue1289118] timedelta multiply and divide by floating point

2010-04-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: This is in a way more similar to issue1083 than to issue2706. I am -1 on this RFE for the same reason as I am opposing allowing true division of timedelta by an int. The timedelta type is fundamentally an integer type. A type delta is just a certain

[issue1289118] timedelta multiply and divide by floating point

2010-04-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I meant rejecting issue1083, of course. -- ___ Python tracker <http://bugs.python.org/issue1289118> ___ ___ Python-bug

[issue5516] equality not symmetric for subclasses of datetime.date and datetime.datetime

2010-04-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: There is another inconsistency that this patch does not seem to cure. With patch applied and D and DT defined as in OP, >>> D(1900,1,1) > DT(1900,1,1) True but >>> DT(1900,1,1) < D(1900,1,1) Traceback (most recent call last

[issue5516] equality not symmetric for subclasses of datetime.date and datetime.datetime

2010-04-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Upon further reflection I am -1 on this patch. First, as implemented this patch changes behavior of an explicit invocation of date.__eq__. The patch proposes to remove the following tests: -# Neverthelss, comparison should work with the base

[issue2706] datetime: define division timedelta/timedelta

2010-04-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Can someone (Mark?) add an acknowledgment for Victor Stinner to the NEWS file? My py3k patch was 90% code from Victor's trunk patch. -- ___ Python tracker <http://bugs.python.org/i

[issue1673409] datetime module missing some important methods

2010-04-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: With issue2706 accepted, I think this issue can now be rejected because proposed td.tosecs() can now be spelled simply as td/timedelta(seconds=1). The other RFE for a totimestamp() method is a duplicate of issue2736. -- nosy

[issue1673409] datetime module missing some important methods

2010-04-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Wed, Apr 21, 2010 at 2:03 PM, Mark Dickinson wrote: .. > (BTW, as well as the newly introduced division methods, td.tosecs already > exists, except that it's spelt td.total_seconds.) Aggrrr! How did that slip in? :-) 8639913600.0

[issue5516] equality not symmetric for subclasses of datetime.date and datetime.datetime

2010-04-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Wed, Apr 21, 2010 at 2:33 PM, Jess Austin wrote: .. > It might seem like the latter behavior is marginally better, but really this > is just a mess, since a date-datetime comparison TypeErrors in all > directions.  I appreciate Alexand

[issue6280] calendar.timegm() belongs in time module, next to time.gmtime()

2010-04-26 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: It is too late to get new features in 2.x. Francesco, Please double-check timemodule-gmtime-r312.diff, it does not seem to reflect your reported changes. ('-' vs '--' typo is still there) There is no need to submit multiple patche

[issue6280] calendar.timegm() belongs in time module, next to time.gmtime()

2010-04-26 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Some more comments: - Documentation needs a "versionadded" entry. - A fate of calendar.timegm() needs to be decided. If the decision is to deprecate it, deprecation warning need to be added to calendar module and docs updated accordingl

[issue8005] datetime's comparison methods do not return NotImplemented when they should

2010-04-27 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Is there a patch with a fix or just a patch with a test. If the later, maybe someone can remove a patch keyword. -- nosy: +Alexander.Belopolsky -belopolsky ___ Python tracker <http://bugs.python.

[issue8005] datetime's comparison methods do not return NotImplemented when they should

2010-04-27 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Before someone spends more time writing a patch, lets pause and consider whether this is a bug in the first place. My understanding of the issue is that given >>> class A(object): ... def __eq__(self, other): ...return True ... OP exp

[issue1636] Execfile unable to take arguments beyond 255!

2010-04-27 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I don't have much to contribute other than a simple test to reproduce the issue: >

[issue8442] Broken zipfile with python 3.2 on osx

2010-04-29 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I cannot reproduce this behavior on my MacBook running OSX 10.6.2. $ ./python.exe Lib/test/test_distutils.py ... -- Ran 168 tests in 3.850s OK (skipped=4) Also, cp437 appears to be a

[issue8404] Set operations don't work for dictionary views

2010-04-29 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The patch looks fine. I verified that the new tests pass on trunk and py3k. I am attaching a patch for py3k with a forward port of set opereations and repr tests. -- nosy: +Alexander.Belopolsky Added file: http://bugs.python.org/file17127

[issue8413] String interpolation doesn't work with sys.version_info

2010-04-29 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am not sure fixing this quirk of %-formatting is worth the trouble given that one simply use new style {}-formatting: $ python-c 'import sys; print("{}.{}.{}-{}-{}".format(*sys.version_info))' 3.2.0-alpha-0 or a work-around $ p

[issue8413] String interpolation doesn't work with sys.version_info

2010-04-29 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The recommended way to check that an object is an instance of a namedtuple is to check for the _fields attribute. See issue7796, msg99869. -- ___ Python tracker <http://bugs.python.org/issue8

[issue8413] String interpolation doesn't work with sys.version_info

2010-04-29 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Thu, Apr 29, 2010 at 11:52 AM, Raymond Hettinger wrote: .. > IIRC, there is an open ticket to make structseq inherit from tuple to avoid > just this kind of problem. > Indeed, see

[issue665761] reduce() masks exception

2010-04-30 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am attaching a patch with unit tests that implements the "middle-ground approach" making map and reduce behave the way zip is now. I my view this slightly preferable to the "all the way" approach of letting all exceptions

[issue1533] Bug in range() function for large values

2010-04-30 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I agree that this issue should be closed with no further action, but for historical accuracy the resolution should be "out of date" rather than "won't fix". The original bug was about range() behavior when it get argument

[issue5109] array.array constructor very slow when passed an array object.

2010-04-30 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Attached patch makes array(t, a) use memcpy when t == a.typecode. The code array_new can probably be refactored to eliminate redundant checks, but with a good C compiler this probably have no performance effect. While refactoring can simplify the code

[issue1533] Bug in range() function for large values

2010-05-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Sat, May 1, 2010 at 3:50 AM, Mark Dickinson wrote: > > Mark Dickinson added the comment: > > Alexander: range *does* still accept such arguments (in 2.7);  just not > floats: > >>>> from decimal import Decimal >

[issue1533] Bug in range() function for large values

2010-05-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Sat, May 1, 2010 at 10:59 AM, Mark Dickinson wrote: > > Mark Dickinson added the comment: > > Decimal is behaving in exactly the same way as MyInt, isn't it? > What do you get for range(MyInt(20), MyInt(20))? > Hmm, maybe

[issue1533] Bug in range() function for large values

2010-05-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Robert, Your patch segfaults on Lib/test/test_builtin.py, but I agree with the approach. I'll see if it is easy to fix. -- ___ Python tracker <http://bugs.python.org/i

[issue1533] Bug in range() function for large values

2010-05-01 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- assignee: -> belopolsky nosy: +belopolsky -Alexander.Belopolsky ___ Python tracker <http://bugs.python.org/iss

[issue1533] Bug in range() function for large values

2010-05-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am attaching a patch which does not crash or leak (as tested with -R :) and adds a unit test for OP's case. The problem, however is that it does not work if new style classes are used in the test case. See disabled (with if 0) test in the

[issue1533] Bug in range() function for large values

2010-05-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Mark, I did not see your last comment before uploading the last patch. I think your suggestion to bypass PyNumber_Long will fix the new/old style classes discrepancy. -- ___ Python tracker <h

[issue1533] Bug in range() function for large values

2010-05-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: This patch, bltinmodule4.diff, seems to work for all cases. Mark, It looks like I came up with almost the same logic as you did. The only difference that I can see is that your code does not check that nb_int returns an integer. Also I put repeated

[issue1533] Bug in range() function for large values

2010-05-01 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Added file: http://bugs.python.org/file17176/bltinmodule4.diff ___ Python tracker <http://bugs.python.org/issue1533> ___ ___ Python-bug

[issue1533] Bug in range() function for large values

2010-05-01 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17175/bltinmodule4.diff ___ Python tracker <http://bugs.python.org/issue1533> ___ ___ Python-bug

[issue1533] Bug in range() function for large values

2010-05-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Attached patch, issue1533.diff, simplifies reference acrobatics at the expense of extra local variables. For the first time the first compilation did not have reference counting errors! -- Added file: http://bugs.python.org/file17189/issue1533

[issue1533] Bug in range() function for large values

2010-05-02 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file9543/bltinmodule.diff ___ Python tracker <http://bugs.python.org/issue1533> ___ ___ Python-bug

[issue1533] Bug in range() function for large values

2010-05-02 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17176/bltinmodule4.diff ___ Python tracker <http://bugs.python.org/issue1533> ___ ___ Python-bug

[issue1533] Bug in range() function for large values

2010-05-02 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17171/bltinmodule3.diff ___ Python tracker <http://bugs.python.org/issue1533> ___ ___ Python-bug

[issue1533] Bug in range() function for large values

2010-05-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Sun, May 2, 2010 at 4:37 AM, Mark Dickinson wrote: .. >  - Please could you also add a test for small arguments for each test >   class? Working on it ... -- ___ Python tracker <http://bugs.p

[issue1533] Bug in range() function for large values

2010-05-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > - Please could you also add a test for small arguments for each test > class? Done. -- Added file: http://bugs.python.org/file17190/issue1533.diff ___ Python tracker <http://bugs.python.org/

[issue1533] Bug in range() function for large values

2010-05-02 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17189/issue1533.diff ___ Python tracker <http://bugs.python.org/issue1533> ___ ___ Python-bug

[issue3720] segfault in for loop with evil iterator

2010-05-02 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- keywords: +26backport ___ Python tracker <http://bugs.python.org/issue3720> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue6763] Crash on mac os x leopard in mimetypes.guess_type (or PyObject_Malloc)

2010-05-02 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- assignee: -> ronaldoussoren components: +Macintosh ___ Python tracker <http://bugs.python.org/issue6763> ___ ___ Python-

[issue665761] reduce() masks exception

2010-05-03 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- keywords: +needs review stage: unit test needed -> patch review ___ Python tracker <http://bugs.python.org/issue

[issue4806] Function calls taking a generator as star argument can mask TypeErrors in the generator

2010-05-03 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- keywords: +needs review stage: -> patch review ___ Python tracker <http://bugs.python.org/issue4806> ___ ___ Python-

[issue1533] Bug in range() function for large values

2010-05-04 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On May 4, 2010, at 7:27 AM, Mark Dickinson wrote: > > Mark Dickinson added the comment: > > Thanks for the fixes. The latest patch looks good to me. > > Alexander, is it okay for me to commit this? > Sure. Why do you have to

[issue1533] Bug in range() function for large values

2010-05-04 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I see. Let me take a look. BTW, I tried to use tabs for indentation in the patch, but emacs was not always happy about it. Is there some c-mode setting that I don't know about that would take care of that? On May 4, 2010, at 8:34 AM, Mark Dick

[issue1533] Bug in range() function for large values

2010-05-04 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Tue, May 4, 2010 at 8:34 AM, Mark Dickinson wrote: .. > I took the liberty of messing with your patch slightly; I didn't want > to ask you to make further changes since the patch was fine, and my > messing was mostly just to satisfy my

[issue1533] Bug in range() function for large values

2010-05-04 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- assignee: belopolsky -> mark.dickinson ___ Python tracker <http://bugs.python.org/issue1533> ___ ___ Python-bugs-list mai

[issue1533] Bug in range() function for large values

2010-05-04 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Tue, May 4, 2010 at 12:32 PM, Mark Dickinson wrote: > > Mark Dickinson added the comment: > > Applied to trunk in r80758. > > Do people want this to go into 2.6 as well? Also, should additional unit tests forward ported to 3.x? I

[issue1533] Bug in range() function for large values

2010-05-04 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am attaching a py3k patch that adds new tests. Since there are no end user visible changes, I don't believe a Misc/NEWS entry is needed. A commit message may read: Issue #1533: Tests only. Added tests for consistency in range function arg

[issue5727] doctest pdb readline broken

2010-05-04 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- nosy: +belopolsky ___ Python tracker <http://bugs.python.org/issue5727> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue7900] posix.getgroups() failure on Mac OS X

2010-05-05 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The latest patch, os-getgroups-v2.patch, seems to have the same bug as I reported in msg99926: """ The crash that I see is apparently due to underallocated memory: alt_grouplist = PyMem_Malloc(n); should be alt_grouplist = PyMem_Ma

[issue7900] posix.getgroups() failure on Mac OS X

2010-05-05 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Ronald> How did you detect that the modern getgroups implementation Ronald> doesn't query the kernel? That would be very odd. I have just found the source code for getgroups: http://www.opensource.apple.com/source/Libc/Libc-594.1.4/sys/getgro

[issue7900] posix.getgroups() failure on Mac OS X

2010-05-05 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Ronald, Did you forget to attach your patch? I don't see v3. -- ___ Python tracker <http://bugs.python.org/i

[issue8404] Set operations don't work for dictionary views

2010-05-05 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Why do you expect dict_values to support set operations? Dict values unlike keys are not sets, they are more like lists. Set operations of dict_values are not supported in 3.x either. -- nosy: +belopolsky -Alexander.Belopolsky

[issue1533] Bug in range() function for large values

2010-05-05 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > Alexander, do you want to tackle the 2.6 backport? I've never done a maintenance branch backport, but here is my attempt: 1. Checkout release26-maint 2. Apply 80757:80758 diff, fix rejected NEWS patch 3. Ignore 80838:80839 diff - small fl

[issue1533] Bug in range() function for large values

2010-05-05 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- keywords: +26backport versions: -Python 2.7, Python 3.1, Python 3.2, Python 3.3 ___ Python tracker <http://bugs.python.org/issue1

[issue1533] Bug in range() function for large values

2010-05-06 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > the requirements are different for 2.6: floats should give a > DeprecationWarning rather than a TypeError. I thought about it, but the comment in test_builtin.py, # Reject floats when it would require PyLongs to rep

[issue1533] Bug in range() function for large values

2010-05-06 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17231/issue1533-release26-maint.diff ___ Python tracker <http://bugs.python.org/issue1

[issue8637] pydoc should respect MANPAGER over PAGER.

2010-05-06 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Similar logic can be written simpler as use_pager = os.environ.get('MANPAGER') or os.environ.get('PAGER') if use_pager: ... (yes, I think ignoring empty *PAGER is preferable to an error) I am not sure, pydoc should respec

[issue8636] enumerate() test cases do not cover optional start argument

2010-05-06 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The patch looks fine, but I wonder if regrtest.py could be taught to warn about situations like this. Maybe run_unitest() should check that all leaf subclasses of TestCase in the module are covered. Ideally, of course, test_main() should be made

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am attaching a patch for py3k branch. I am +1 for backporting to 2.7 and I avoided relying on py3k timedelta/timedelta in the patch. The tests and docs will need to be modified for the backport. Technically speaking, this is a change in documented

[issue7900] posix.getgroups() failure on Mac OS X

2010-05-07 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- stage: unit test needed -> patch review ___ Python tracker <http://bugs.python.org/issue7900> ___ ___ Python-bugs-list mai

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > (1) there should be a Py_DECREF(total_microseconds) ... Yes, regrtest -R is not a substitute for thinking. > (2) in the docstring, replace 'loose' by 'lose' > Neither is spellcheck. :-) > (3) also in the docstring, I

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17246/issue8644-py3k.diff ___ Python tracker <http://bugs.python.org/issue8644> ___ ___ Pytho

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Added file: http://bugs.python.org/file17255/issue8644-py3k.diff ___ Python tracker <http://bugs.python.org/issue8644> ___ ___ Python-bug

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17254/issue8644-py3k.diff ___ Python tracker <http://bugs.python.org/issue8644> ___ ___ Pytho

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Sat, May 8, 2010 at 10:07 AM, Mark Dickinson wrote: .. > I definitely think this should go into 2.7 as well;  total_seconds has only > seen the light of day > in the beta releases so far, so it's unlikely we'd break anyone's

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17266/issue8644.diff ___ Python tracker <http://bugs.python.org/issue8644> ___ ___ Python-bug

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Added file: http://bugs.python.org/file17267/issue8644.diff ___ Python tracker <http://bugs.python.org/issue8644> ___ ___ Python-bug

[issue8425] a -= b should be fast if a is a small set and b is a large set

2010-05-09 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- nosy: +belopolsky ___ Python tracker <http://bugs.python.org/issue8425> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue8425] a -= b should be fast if a is a small set and b is a large set

2010-05-10 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The problem is apparently due to the fact that small_set -= large_set iterates over the large set removing entries from small_set while more efficient small_set - large_set builds a new set iterating over a small_set and adding items that are not in the

[issue8425] a -= b should be fast if a is a small set and b is a large set

2010-05-10 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- stage: needs patch -> patch review ___ Python tracker <http://bugs.python.org/issue8425> ___ ___ Python-bugs-list mai

[issue8425] a -= b should be fast if a is a small set and b is a large set

2010-05-10 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On the second thought, it is possible to preserve set identity and avoid iteration over a large set. See issue8425a.diff attached. It looks like the unit tests don't check identity preservation. I will submit additional tests sh

[issue8425] a -= b should be fast if a is a small set and b is a large set

2010-05-10 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Added file: http://bugs.python.org/file17284/issue8425-tests.diff ___ Python tracker <http://bugs.python.org/issue8425> ___ ___ Pytho

[issue8425] a -= b should be fast if a is a small set and b is a large set

2010-05-10 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Note that issue8425a.diff leaves small_set.difference_update(large_dict) unoptimized: $ ./python.exe -m timeit -s "s = {1}; l = dict.fromkeys(range(1000));" "s.difference_update(l)" 1000 loops, best of 3: 842 usec per loop $ ./pyt

[issue8256] TypeError: bad argument type for built-in operation

2010-05-11 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- nosy: +belopolsky ___ Python tracker <http://bugs.python.org/issue8256> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue8685] set(range(100000)).difference(set()) is slow

2010-05-11 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- nosy: +belopolsky ___ Python tracker <http://bugs.python.org/issue8685> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue8685] set(range(100000)).difference(set()) is slow

2010-05-11 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I have two problems with this proposal: 1. In constrained memory environments, creating a temporary internal copy of a large set may cause the difference operation to fail that would otherwise succeed. 2. The break-even point between extra lookups and

[issue8692] Use divide-and-conquer for faster factorials

2010-05-11 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I've noticed that your patch changes >>> math.factorial(2.**63) Traceback (most recent call last): File "", line 1, in OverflowError: Python int too large to convert to C long to >>> math.factorial(2.**63) Tracebac

[issue8692] Use divide-and-conquer for faster factorials

2010-05-11 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I also started to wonder if a tighter upper limit for an acceptable argument can be found. In discussion of issue2138 I saw the following exchange: """ > Should there be some upper limit on the argument math.factorial would take?

[issue8692] Use divide-and-conquer for faster factorials

2010-05-11 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Tue, May 11, 2010 at 7:42 PM, Daniel Stutzbach wrote: .. > Isn't that adding an extra check in every case to speed up a > you-can't-seriously-expect-that-to-work corner case? > The check is cheap - just a machine integer compari

[issue8692] Use divide-and-conquer for faster factorials

2010-05-11 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Tue, May 11, 2010 at 7:42 PM, Daniel Stutzbach wrote: .. > Isn't that adding an extra check in every case ... Speaking of micro-optimizations, did you consider a better than naive algorithm for "Count the number of set bits in n&q

[issue8692] Use divide-and-conquer for faster factorials

2010-05-11 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Tue, May 11, 2010 at 9:07 PM, Daniel Stutzbach wrote: > > Daniel Stutzbach added the comment: > > On Tue, May 11, 2010 at 7:38 PM, Alexander Belopolsky > wrote: >> Speaking of micro-optimizations, did you consider a better th

[issue8692] Use divide-and-conquer for faster factorials

2010-05-11 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Tue, May 11, 2010 at 10:19 PM, Alexander Belopolsky wrote: .. > Similarly, while unlikely to improve performance, I would prefer not > to use any bit-trick implementation of ilog2 (in a separate function, > of course) instead of calling float

[issue8692] Use divide-and-conquer for faster factorials

2010-05-12 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Tue, May 11, 2010 at 5:58 PM, Mark Dickinson wrote: > Yes, I'm interested in seeing the pure Python version. Here is my translation of the reference implementation. > It could go into test_math, and would be a useful form of documenta

[issue8692] Use divide-and-conquer for faster factorials

2010-05-12 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Tue, May 11, 2010 at 10:19 PM, Alexander Belopolsky wrote: .. > Another readability nit:  for me k % 2 == 0 is a more readable check > for even number than (k & 1) != 1.  Performance-wise the two choices > are the same, and either can b

[issue8692] Use divide-and-conquer for faster factorials

2010-05-12 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Wed, May 12, 2010 at 4:50 AM, Mark Dickinson wrote: .. > (4) I wonder whether the recursion in factorial_part_product slows things > down;  it might be interesting to compare with an iterative version (but > still one that clumps toget

[issue8692] Use divide-and-conquer for faster factorials

2010-05-12 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Here is one more datapoint. $ ./python.exe -m timeit -s "import factorial4 as fm; fm.partial_product = fm.partial_product; f = fm.factorial " "f(1)" 10 loops, best of 3: 66.1 msec per loop [32794 refs] $ ./python.exe -m timeit -

[issue8692] Use divide-and-conquer for faster factorials

2010-05-13 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Daniel, Your variant does not seem to work: >>> def partial_product3(j, i): ... a = [l << 1 | 1 for l in range(j, i + 1)] ... n = len(a) ... while 1: ... if n == 1: ... return a[0] ... half = n//2

[issue8692] Use divide-and-conquer for faster factorials

2010-05-13 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Thu, May 13, 2010 at 5:31 PM, Mark Dickinson wrote: > And why are we trying to speed up the pure Python factorial code here? I would expect that for large factorials the performance will be determined by the number of long multiplications and

[issue8692] Use divide-and-conquer for faster factorials

2010-05-13 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17313/factorial4.py ___ Python tracker <http://bugs.python.org/issue8692> ___ ___ Python-bug

[issue8692] Use divide-and-conquer for faster factorials

2010-05-13 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Thu, May 13, 2010 at 6:09 PM, Daniel Stutzbach wrote: .. > Speaking of getting side-tracked, I didn't see an answer to a question I asked > earlier.  I'd like to get some feedback before I proceed with revising the > patch. I did

[issue8692] Use divide-and-conquer for faster factorials

2010-05-13 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Wed, May 12, 2010 at 3:47 PM, Mark Dickinson wrote: >... > Realistically though, I don't see an iterative version of > factorial_part_product as > an option for the C patch, without a significant increase in complexity. >  Dani

[issue8692] Use divide-and-conquer for faster factorials

2010-05-13 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Thu, May 13, 2010 at 5:58 PM, Mark Dickinson wrote: > Optimizations that speed up, say, factorial(n) for n <= 1000 would seem more >valuable. I am attaching a variant of my patch which precomputes partial products that fit in 32 bit uns

[issue8692] Use divide-and-conquer for faster factorials

2010-05-13 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Oh, my! How did that last term get into precomputed list?! It should have been precomputed[] = {3, 15, 5, 35, 315, 63, 693, 9009, 1287, 19305, 328185, 36465, 692835, 14549535, 1322685, 30421755, 760543875, 58503375, 1579591125ul

<    7   8   9   10   11   12   13   14   15   16   >