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

2010-05-13 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Added file: http://bugs.python.org/file17327/factorial-precompute-partials.patch ___ Python tracker <http://bugs.python.org/issue8

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

2010-05-13 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17327/factorial-precompute-partials.patch ___ Python tracker <http://bugs.python.org/issue8

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

2010-05-13 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17325/factorial-precompute-partials.patch ___ Python tracker <http://bugs.python.org/issue8

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

2010-05-13 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Added file: http://bugs.python.org/file17328/factorial-precompute-partials.patch ___ Python tracker <http://bugs.python.org/issue8

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

2010-05-13 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Mark> Does anyone feel like doing a speed comparison between Daniel's C patch and a version with a direct no-frills iterative version of factorial_part_product (i.e., just a simple 'for (i = n; i <= m; i += 2) { }? Not a direc

[issue1545463] New-style classes fail to cleanup attributes

2008-01-30 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The problem still exists in 2.5.1. The explanations given so far are not correct. With x.py as before (see attached): >>> import sys, gc, x creating X('new') creating X('old') >>> del x,sys.modules['x'] de

[issue2000] Undefined symbols: _PyOS_mystrnicmp on Mac OS X

2008-02-02 Thread Alexander Belopolsky
New submission from Alexander Belopolsky: On Mac OS X, make fails with the following error .. /usr/bin/ld: Undefined symbols: _PyOS_mystrnicmp collect2: ld returned 1 exit status make: *** [python.exe] Error 1 The attached patch fixes the issue. -- components: Build files: make

[issue2000] Undefined symbols: _PyOS_mystrnicmp on Mac OS X

2008-02-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Looks like an SVN problem on my end. I am getting a stale version of the makefile. Please close the issue as invalid. __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/

[issue2021] Turn NamedTemporaryFile into a context manager

2008-02-06 Thread Alexander Belopolsky
New submission from Alexander Belopolsky: In the spirit of files becoming context managers in 2.5, the attached patch defines __enter__ and __exit__ methods for tempfile.NamedTemporaryFile. BTW, I was not able to add a "patch" keyword which seems appropriate here. --

[issue2016] Crash when modifying the **kwargs passed to a function.

2008-02-06 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: It also appears that the tuple and dict checks in function_call are redundant. If there is a use case that results in function_call getting anything (non null) other than dict and tuple in arg and kw, I don't think silently ignoring such arguments i

[issue2016] Crash when modifying the **kwargs passed to a function.

2008-02-06 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Sorry, please ignore my last comment about arg. The null and tuple checks are for argdefs, not arg. __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/

[issue2016] Crash when modifying the **kwargs passed to a function.

2008-02-06 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: According to http://docs.python.org/api/object.html, """ PyObject* PyObject_Call(PyObject *callable_object, PyObject *args, PyObject *kw) Return value: New reference. Call a callable Python object callable_object, with arg

[issue2021] Turn NamedTemporaryFile into a context manager

2008-02-10 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Nick's comment made me think why NamedTemporaryFile can't simply subclass file and get properly working context manager's methods for free. It turned out that although file is subclassable, in its present form, it does not allow Nam

[issue2067] file.__exit__ does not call subclass' close method

2008-02-11 Thread Alexander Belopolsky
New submission from Alexander Belopolsky: Attached patch makes file.__exit__ call subclass' close method. -- components: Interpreter Core files: file_exit.diff messages: 62289 nosy: belopolsky severity: normal status: open title: file.__exit__ does not call subclass' close m

[issue1286] fileinput, StringIO, and cStringIO do not support the with protocol

2008-02-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Attached patch implements context management protocol for StringIO. -- components: +Library (Lib) nosy: +belopolsky versions: -Python 3.0 Added file: http://bugs.python.org/file9470/with_StringIO.diff __ Tracker

[issue1040026] os.times() is bogus

2008-02-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On i386 Linux, HZ is #defined as sysconf(_SC_CLK_TCK) /usr/include/asm-i386/param.h:7:#define HZ sysconf(_SC_CLK_TCK) so times does the right thing. On x86_64 HZ is defined as 100, but it is the same value as sysconf returns. I could not find an

[issue1877] unhelpful error when calling "python "

2008-02-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Actually, a very simple change restores python2.5 behavior: === --- Modules/main.c (revision 60941) +++ Modules/main.c (working copy) @@ -187,6 +187,7 @@ if ((argv0

[issue1877] unhelpful error when calling "python "

2008-02-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I have found relevant documentation in a comment preceding get_path_importer definition: ... traverse path_hooks until a hook is found that can handle the path item. Return None if no hook could; this tells our caller it should fall back to

[issue2160] Document PyImport_GetImporter

2008-02-21 Thread Alexander Belopolsky
New submission from Alexander Belopolsky: See attached patch. -- components: Documentation files: doc-import.diff messages: 62678 nosy: belopolsky severity: normal status: open title: Document PyImport_GetImporter versions: Python 2.6 Added file: http://bugs.python.org/file9487/doc

[issue2051] PYO file permission problem

2008-02-21 Thread Alexander Belopolsky
Changes by Alexander Belopolsky: Added file: http://bugs.python.org/file9488/issue2051.diff __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2051> __ ___ Pyth

[issue2051] PYO file permission problem

2008-02-21 Thread Alexander Belopolsky
Changes by Alexander Belopolsky: -- nosy: +belopolsky __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2051> __ ___ Python-bugs-list mailing list Unsubs

[issue1481296] long(float('nan'))!=0L

2008-02-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: FYI: IEEE Standard 754 requires an invalid operation exception when inf/nan conversion to integer is attempted. -- nosy: +belopolsky _ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/iss

[issue1877] unhelpful error when calling "python "

2008-02-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Nick, I understand the __main__.py issue now, but I still don't like your approach. Allowing RunMainFromImporter to call exit and never return does not feel right. (A minor problem is that objects on the C stack do not get deleted.) Without a

[issue1877] unhelpful error when calling "python "

2008-02-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I think a more elegant solution will be possible if issue2135 patch is accepted. I suggest to reopen this issue for Py3k pending resolution of issue2135. __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/

[issue2135] Restructure import.c into PEP 302 importer objects

2008-02-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The patch breaks test_import on Mac OS 10.4: $ ./python.exe -E -tt -bb ./Lib/test/regrtest.py test_import test_import test test_import failed -- Traceback (most recent call last): File "./Lib/test/regrtest.py", line 1199, in main() F

[issue2135] Restructure import.c into PEP 302 importer objects

2008-02-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I've noticed that the proposed patch adds const qualifier to many C-API functions' arguments. While at the first glance these changes are reasonable, they add clutter to the already massive patch. I would recommend to separate const qualifi

[issue2135] Restructure import.c into PEP 302 importer objects

2008-02-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: First, let me state that I like the idea of a uniform approach to importing, but given the complexity of the task, Brett's approach (which I understand as implementing the builtin importer classes in Python) would make sense (as long as he can solv

[issue1540617] Use Py_ssize_t for rangeobject members

2008-02-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: issue1546078 presents a much more ambitious patch - supporting arbitrary longs in range. It looks like that patch was applied to py3k branch where performance issues are not yet a concern. Unless there are plans to backport 1546078, I would like to see

[issue1540617] Use Py_ssize_t for rangeobject members

2008-02-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Yes, index/longindex optimization is nice and can be applied to xrange. However, I don't think python-dev will be happy with the 1546078-style changes going to 2.6 and optimization patches are probably premature for 3.0. The ssize_t approach

[issue1877] unhelpful error when calling "python "

2008-02-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Nick, you are right about sys.exit(). I did to much C programming lately and forgot that sys.exit() does not exit. :-) I understood your comment as saying that 'importer' points to a valid importer. Now I understand that with the present st

[issue1040026] os.times() is bogus

2008-02-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: os_times3.PATCH works for me on Mac OS 10.4 and RHEL. I have a few comments on the patch: 1. sysconf return type is long, not clock_t 2. If sysconf is present, but _SC_CLK_TCK is not supported, it will return -1. In this case we should fall back to

[issue1040026] os.times() is bogus

2008-02-23 Thread Alexander Belopolsky
Changes by Alexander Belopolsky: _ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1040026> _ ___ Python-bugs-list mailing list Unsubscribe: http://mai

[issue2144] os.environ should inherit dict

2008-02-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Small comment on the patch: def clear(self): -for key in self.data.keys(): +for key in self.keys(): unsetenv(key) -del self.data[key

[issue1367711] Remove usage of UserDict from os.py

2008-02-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I would say dict's failure to call overloaded __setitem__ from setdefault is a dict implementation problem which should be either fixed, or clearly documented as warning to anyone who wants to derive from dict. A fix would be tr

[issue2144] os.environ should inherit dict

2008-02-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > dict doesn't dynamically bind any calls; to > properly replace the semantics of dict, you > have to implement *all* API. What was the rationale for this decision? To me it looks like a hold- over from the time when dicts were not subclass

[issue2144] os.environ should inherit dict

2008-02-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: First, if the new thread on dict behavior does not make sense, please see discussion at issue1367711 where it started. (My mistake following up here.) Second, the ability to subclass built-in type is such a great feature, that it is a shame that doing

[issue2144] os.environ should inherit dict

2008-02-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > The builtins make direct calls to their own internal methods. Raymond, I guess issue2067 escaped your review. :-) __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.o

[issue2144] os.environ should inherit dict

2008-02-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Let's get back on-topic. I assume you are recommending to close this issue by rejecting the patch. I disagree. The patch can be fixed to properly override all methods and a unit test can be added to guarantee that all dict methods are overr

[issue1367711] Remove usage of UserDict from os.py

2008-02-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: See comments at issue2144. Benjamin Peterson demonstrated a more than 2x speedup on a micro-benchmark. Plus, the fact that two people were motivated enough to independently produce a near-complete patch is worth something

[issue1040026] os.times() is bogus

2008-02-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > 1. .. It's preferable to cast into a clock_t immediately rather than > doing a conversion for each of the ensuing divisions. If that's your motivation, then you should cast to double instead. However, I would leave it to comp

[issue1040026] os.times() is bogus

2008-02-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Aha, I should read my own sources: "The value shall not change during the lifetime of the calling process, [XSI] except that sysconf(_SC_OPEN_MAX) may return different values before and after a call to setrlimit() which changes the RLIMIT_NOFILE

[issue1040026] os.times() is bogus

2008-02-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: FWIW, the following minimal patch fixed the bug on MacOS X and does not affect Linux: === --- Modules/posixmodule.c (revision 61014) +++ Modules/posixmodule.c (working copy

[issue2144] os.environ should inherit dict

2008-02-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Did anyone mention "clutch"? :-) Oh, well, please close issue1367711 as a duplicate. __ Tracker <[EMAIL PROTECTED]> <http://bugs.p

[issue2172] Add doc-string to UserDict and DictMixin

2008-02-23 Thread Alexander Belopolsky
New submission from Alexander Belopolsky: Attached patch improves pydoc UserDict presentation. One of the problems with the current documentation in comments is that order of methods is not preserved and thus the method level comments in DictMixin implementation are meaningless in pydoc. (In

[issue2172] Add doc-string to UserDict and DictMixin

2008-02-23 Thread Alexander Belopolsky
Changes by Alexander Belopolsky: Added file: http://bugs.python.org/file9530/UserDict-doc.diff __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2172> __ ___ Pyth

[issue2172] Add doc-string to UserDict and DictMixin

2008-02-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Fixed an error in lavels doc. Needs review. __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2172> __ ___ Python-bugs-list

[issue2172] Add doc-string to UserDict and DictMixin

2008-02-23 Thread Alexander Belopolsky
Changes by Alexander Belopolsky: -- components: +Documentation versions: +Python 2.6 __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2172> __ ___ Pyth

[issue1040026] os.times() is bogus

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Here is my take (posixmodule.diff). When ticks per seconds cannot be determined, python should not provide times rather than refuse to build. Initialization moved to the init function. -- keywords: +patch Added file: http://bugs.python.org

[issue1040026] os.times() is bogus

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > I'd prefer a noisy compile error .. That would be fine if you could verify that none of the currently supported platforms will be affected. I would still feel uneasy about refusing to build python simply because os.times is not ported to a

[issue1040026] os.times() is bogus

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > You complained in msg62869 about the original patch that calling sysconf > on every call leads to an unacceptable slowdown. Your one-line patch > calls sysconf five times on each call when HZ is not defined. That's why I said that w

[issue1040026] os.times() is bogus

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > HZ may be defined on your machine, but it isn't on my (Xeon) machine. Are you sure? Please note that HZ will not show up in grep -w HZ /usr/include because the right header file further up the tree. On Solaris: /usr/include/sys/param.h

[issue1040026] os.times() is bogus

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Thanks Cristian for your intervention. This bug is clearly an aberration: how many GvR reported bugs do you know that stayed open for 3+ years? I think posixmodule.diff satisfies all your requirements and was not opposed by anyone except yours truly

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

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: This is related to issue1540617 and issue1546078. issue1540617 contains a simple patch that extend acceptable range of argument to +/-2**63 issue1546078 contains a complete long integer support implementation and was accepted in Py3k. It looks like

[issue1540617] Use Py_ssize_t for rangeobject members

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > enumerate() and itertools.count() both > show how to support arbitrary longs without > killing the performance of common cases. Unlike enumerate() and count(), range object has 3 integer members: start, step and len. Doubling all of them as

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

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Christian, I was probably a bit sloppy using "range" instead of "xrange," but issue1540617 is limited to xrange only. Are you still -10 on extending xrange on 64-bit platforms to +/- 2**63? If so, what is your position on backport

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

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > So far the memory for the ints is *never* returned > to the system. I'm working on the problem. Christian, Are you working on the memory problem or on this issue? I think I have a solution to OP's problem, but don't want to

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

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Attached patch addresses OP's issue: $ ./python.exe bad_range.py [8, 9, 10, 11, 12, 13, 14, 15, 16, 17] here [18446744073709551616L, 18446744073709551617L, 18446744073709551618L, 18446744073709551619L, 18446744073709551620L, 1844674407370955

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am not sure what this patch would accomplish. I tried $ cat t.py def f(): return 1 1+2 from dis import dis print dis(f) Both with and without patch I get $ ./python.exe -O t.py 2 0 LOAD_CONST 1 (1) 3

[issue1772673] Replacing char* with const char*

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Douglas Greiman submitted many similar changes with his issue2135 patch. His patch also amends documentation, which is missing here. I am adding dgreiman to the nosy list here to avoid duplication of effort. I am -0 on the idea. -- nosy

[issue1766304] improve xrange.__contains__

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > Do we really need another way to spell a <= x < b? Have you got a > real-world use case in mind for the version with step > 1? > I'm at most lukewarm; I'd be willing to look at a patch to the C code > in the py3k-struni

[issue2186] map and filter shouldn't support None as first argument (in Py3k only)

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: In the absence of an identity function, map accepting None is useful in the cases like this: converters = {..} y = map(converters.get(c), x) That will now have to be rewritten as conv = converters.get(c) if conv is None: y = list(x) else: y = map

[issue1540617] Use Py_ssize_t for rangeobject members

2008-02-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > What specific event triggered your working on this? That was a long time ago, but IIRC, we had some code dealing with large files that grew up beyond 2G. The files contained fixed-length records and we used xrange to iterate over record offsets.

[issue2186] map and filter shouldn't support None as first argument (in Py3k only)

2008-02-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Attached patch removes support for None from filter and itertools.ifilter. My objections for removing that from map do not apply because bool function can be used instead of None in filter achieving similar performance and better clarity. None support

[issue2187] map and filter objects shouldn't call themselves itertools.imap and itertools.ifilter objects

2008-02-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Can you assign this to Raymond as well? If this is done first, issue2186 patch will be simpler (at least in the documentation portion). The same question on the fate of ifilterfalse is pertinent here as well. -- nosy: +belopolsky

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I figured that out: >>> def g(): ... raise RuntimeError ... Before the patch: >>> dis(g) 2 0 LOAD_GLOBAL 0 (RuntimeError) 3 RAISE_VARARGS1 6 LOAD_CONST

[issue2186] map and filter shouldn't support None as first argument (in Py3k only)

2008-02-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Raymond, There must be a reason why we constantly disagree. Do you live in California by any chance? :-) I am not sure if map(None, ..) fate is still up for voting given your changes at r60206, but your own patch illustrates the problem that I

[issue2186] map and filter shouldn't support None as first argument (in Py3k only)

2008-02-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Raymond, it looks like you just broke the build for me: /Users/sasha/Work/python-svn/trunk/Modules/itertoolsmodule.c: In function 'ifilter_next': /Users/sasha/Work/python-svn/trunk/Modules/itertoolsmodule.c:2058: error: invalid operands

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Attached patch adds test_elim_unreachable() unit test. Last two assertions should fail with unpatched python. I am still trying to convince myself that the transformation are correct. > I propose that codestr[] array is made one byte > long

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Paul, You are right. I misunderstood that comment myself. I've tried the attached modification to your patch (unreachable-code-1.diff) and it passes all tests while fixing msg62953 problem: $ cat t.py def f(): return 1 1+2 from dis i

[issue2186] map and filter shouldn't support None as first argument (in Py3k only)

2008-02-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > What do you guys think about just making the predicate argument > optional? You've read my mind! That what I was going to suggest if I realized that optional argument does not have to be the last one. Looks like it would make se

[issue2186] map and filter shouldn't support None as first argument (in Py3k only)

2008-02-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > I think the motivation behind your other use case will likey be > addressed in a more general way with an identify function being > added to the operator module. Quite true, but I thought operator.identity was dead and buried. Can y

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-26 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I have added more tests as Neal suggested. See unreachable-code-with- tests.diff for a combined patch. I've rerun all tests after removing .pyc files and also with -O option (ensuring no existing .pyo files as well). All works. I've rem

[issue1673203] add identity function

2008-02-26 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Raymond Hettinger wrote in msg63027 (issue2186): """ .. it looks like there [is an] agreement on dropping None for map() and going forward with the operator.identity() patch. Will check these in in the next couple of days. "&quo

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-26 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > Since you don't increment codelen .. Good catch! > For this reason, if() before > writing the RETURN_VALUE is not needed. In this case it will be clearer to use STOP_CODE instead of RETURN_VALUE

[issue2197] Further simplify dict literal bytecode

2008-02-26 Thread Alexander Belopolsky
New submission from Alexander Belopolsky: I am attaching a proof-of-concept patch that changes the bytecode generated from {1:1,2:2,3:3,4:4} from BUILD_MAP4 LOAD_CONST 2 (1) LOAD_CONST 2 (1) STORE_MAP LOAD_CONST 1 (2

[issue2197] Further simplify dict literal bytecode

2008-02-26 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Hmm, it looks like this was considered before (issue402227), but back then there were no set literals. If stack-saving approach is better for dicts, it should be better for sets as well. In any case, maybe it is time to revisit the issue and decide on

[issue2197] Further simplify dict literal bytecode

2008-02-27 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I did not think of the insertion after creation change of semantics. Do I understand that this is important when keys have custom comparison/hash methods with side-effects. If it is important for the language to guarantee the create/insert order in

[issue2183] optimize list comprehensions

2008-02-27 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The patch looks reasonable to me. Bytecode docs need to be changed. At minimum like this: === --- Doc/library/dis.rst (revision 61097) +++ Doc/library/dis.rst (working copy) @@ -463,9 +463,9

[issue2185] code objects should conserve memory

2008-02-27 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Since names and varnames are known to be tuples of interned strings, they can be compared without calling abstract API. Just compare sizes and then compare item pointers in a loop. What are the cases when co_names == co_varnames? How often is this the

[issue1766304] improve xrange.__contains__

2008-02-29 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Here are my comments on the py3k patch: 1. Sign of a PyLong object o is the same as the sign of Py_SIZE(o). I would think it is safe to use this fact within python core. (User code that may need to work across multiple versions of python may need to

[issue2222] Memory leak in os.rename?

2008-03-03 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: It looks like non-windows code has a similar problem: static PyObject * posix_2str(PyObject *args, char *format, int (*func)(const char *, const char *)) { char *path1 = NULL, *path2 = NULL; int res; if

[issue2179] with should be as fast as try/finally

2008-03-03 Thread Alexander Belopolsky
Changes by Alexander Belopolsky: -- nosy: +belopolsky __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2179> __ ___ Python-bugs-list mailing list Unsubs

[issue2223] regrtest.py -R not working

2008-03-03 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: It looks like you are running regrtest from the trunk with the py3k interpretor. Works for me. -- nosy: +belopolsky __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/

[issue2223] regrtest.py -R not working

2008-03-03 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: attached simple patch seems to fix the problem but should be reviewed by Christian. -- keywords: +patch Added file: http://bugs.python.org/file9596/regrtest.patch __ Tracker <[EMAIL PROTECTED]>

[issue2223] regrtest.py -R not working

2008-03-03 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > Can you test it on your machine please? Running on a 4-core Opteron (2.6GHz). Should complete in an hour or so ... __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.o

[issue2223] regrtest.py -R not working

2008-03-03 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: test_collections fails (with -R :: only). Does not look like something related to the recent changes, rather test is not happy about being repeated. $ ./python Lib/test/regrtest.py -R :: test_collections test_collections beginning 9 repetitions

[issue2198] code_hash() can be the same for different code objects

2008-03-03 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I would say filename/lineno are excluded from hash on purpose because they are ignored in comparisons: >>> compile("0", "a", "eval") == compile("0", "b", "eval") True Include/code.h

[issue2223] regrtest.py -R not working

2008-03-03 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Here are the results from regrtest.py -R :: .. 301 tests OK. 7 tests failed: test_collections test_cprofile test_frozen test_inspect test_logging test_pkg test_profile .. $ cat reflog.txt test_cmd_line leaked [-23, 0, 0, 23] references, sum=0

[issue2230] Document PyArg_Parse* behavior on failed conversion

2008-03-03 Thread Alexander Belopolsky
New submission from Alexander Belopolsky: Much of existing code relies on PyArg_Parse* leaving C variables unmodified when conversion failed. Attached patch documents that behavior. -- files: doc-arg.diff keywords: patch messages: 63243 nosy: belopolsky severity: normal status: open

[issue2230] Document PyArg_Parse* behavior on failed conversion

2008-03-03 Thread Alexander Belopolsky
Changes by Alexander Belopolsky: -- components: +Documentation severity: normal -> minor type: -> feature request versions: +Python 2.3, Python 2.4, Python 2.5, Python 2.6, Python 3.0 __ Tracker <[EMAIL PROTECTED]> <http://bugs.pytho

[issue2222] Memory leak in os.rename?

2008-03-04 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The affected code is the only case I could find in stdlib where O& format was used to populate PyObject* variables. Although it appears to be valid usage, the code presents an exception to the following note at http://docs.python.org/dev/c-api/arg.

[issue2231] Memory leak in itertools.chain()

2008-03-04 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Good catch, Hirokazu! The patch looks correct to me. Works as advertised on Mac OS 10.4. -- nosy: +belopolsky __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/

[issue2222] Memory leak in os.rename?

2008-03-04 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On the test_os patch: I would rename LeakTest to ErrorTest and leave it on for all platforms. BTW, I cannot produce a definitive proof that posix_2str leaks when second conversion fails (regrtest -R does not catch it because the leaked buffer is not a

[issue2239] Tiny patch to cmdline docs

2008-03-05 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: PYTHONPATH variable is likely to be defined by sysadmins who may not know what os.pathsep is. Maybe it is better to say "OS-dependent separator (';' on Windows, ':' on Linux and other UNIX-like OSes or ',' on some les

[issue2239] Tiny patch to cmdline docs

2008-03-05 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > .. but I have made the doc reference a link to the os.pathsep I knew you would say that :-). I was making my comment out of real life experience: sysadmins rarely know python language, but can do good job administering python installations.

[issue2239] Tiny patch to cmdline docs

2008-03-05 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > Feel free to propose an alternative wording for the patch I thought I already did in my first post. The complete sentence should read: """ The format is the same as the shell's :envvar:`PATH`: one or more directory pathn

[issue2246] itertools.groupby() leaks memory with circular reference

2008-03-06 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: With the following patch: === --- Lib/test/test_itertools.py (revision 61284) +++ Lib/test/test_itertools.py (working copy) @@ -707,6 +707,12 @@ a = [] self.makecycle

[issue2246] itertools.groupby() leaks memory with circular reference

2008-03-06 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: It looks like the problem is that the internal grouper object becomes a part of a cycle: keyfunc -> grouper(x) -> keyfunc(tgtkey), but its type does not support GC. I will try to come up with a patch. __ Tracker &

[issue2246] itertools.groupby() leaks memory with circular reference

2008-03-06 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Oops. Here is my patch anyways. -- keywords: +patch Added file: http://bugs.python.org/file9625/groupby-leak.diff __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/

[issue1533486] long -> Py_ssize_t (C/API 1.2.1)

2008-03-06 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I think it should be changed to "because sizeof(Py_ssize_t) == sizeof(void*)" -- nosy: +belopolsky _ Tracker <[EMAIL PROTECTED]> <http://bugs.pyth

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