[issue24978] Contributing to Python 2x and 3x Documentation. Translation to Russian.

2015-09-01 Thread Eugene
New submission from Eugene: I am very much begging pardon if this is not the place to ask for, but.. I would like to make a thorough translation of the official Library Reference and the beginners guide to Python 2.x 3.x in Russian language. I am aware this type of translation will be placed

[issue11549] Build-out an AST optimizer, moving some functionality out of the peephole optimizer

2011-06-07 Thread Eugene Toder
Eugene Toder added the comment: Nick, if there's an interest in reviewing the patch I can update the it. I doubt it needs a lot of changes, given that visitor is auto-generated. Raymond, the patch contains a rewrite of low-level optimizations to work before byte code generation,

[issue12290] __setstate__ is called for false values

2011-06-08 Thread Eugene Toder
New submission from Eugene Toder : Pickle documentation [1] says: """ Note: If __getstate__() returns a false value, the __setstate__() method will not be called upon unpickling. """ However, this isn't quite true. This depends on the version of pickle pro

[issue12290] __setstate__ is called for false values

2011-06-08 Thread Eugene Toder
Changes by Eugene Toder : -- nosy: +alexandre.vassalotti, pitrou ___ Python tracker <http://bugs.python.org/issue12290> ___ ___ Python-bugs-list mailing list Unsub

[issue12290] __setstate__ is called for false values

2011-06-15 Thread Eugene Toder
Eugene Toder added the comment: So how about this correction? -- keywords: +patch nosy: +belopolsky, georg.brandl Added file: http://bugs.python.org/file22375/setstate.diff ___ Python tracker <http://bugs.python.org/issue12

[issue5996] abstract class instantiable when subclassing dict

2011-06-15 Thread Eugene Toder
Eugene Toder added the comment: Anyone has any thoughts on this? -- ___ Python tracker <http://bugs.python.org/issue5996> ___ ___ Python-bugs-list mailin

[issue11549] Build-out an AST optimizer, moving some functionality out of the peephole optimizer

2011-06-15 Thread Eugene Toder
Eugene Toder added the comment: I found a problem in constant de-duplication, already performed by compiler, that needs to be fixed before this change can be merged. Compiler tries to eliminate duplicate constants by putting them into a dict. However, "duplicate" in this case do

[issue5996] abstract class instantiable when subclassing dict

2011-07-11 Thread Eugene Toder
Eugene Toder added the comment: They are, when there's a most specific metaclass -- the one which is a subclass of all others (described here http://www.python.org/download/releases/2.2.3/descrintro/#metaclasses, implemented here http://hg.python.org/cpython/file/ab162f925761/Ob

[issue11816] Refactor the dis module to provide better building blocks for bytecode analysis

2011-08-23 Thread Eugene Toder
Changes by Eugene Toder : -- nosy: -eltoder ___ Python tracker <http://bugs.python.org/issue11816> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue6083] Reference counting bug in PyArg_ParseTuple and PyArg_ParseTupleAndKeywords

2010-11-16 Thread Eugene Kapun
Eugene Kapun added the comment: Actually, this can't be fixed without modifying C API methods PyArg_ParseTuple and PyArg_ParseTupleAndKeywords, because it's possible to make an object deallocated before PyArg_ParseTuple returns, so Py_INCREF immediately after parsing would be a

[issue6083] Reference counting bug in PyArg_ParseTuple and PyArg_ParseTupleAndKeywords

2010-11-16 Thread Eugene Kapun
Changes by Eugene Kapun : Added file: http://bugs.python.org/file19617/test-ctypes.py ___ Python tracker <http://bugs.python.org/issue6083> ___ ___ Python-bugs-list mailin

[issue6083] Reference counting bug in PyArg_ParseTuple and PyArg_ParseTupleAndKeywords

2010-11-16 Thread Eugene Kapun
Changes by Eugene Kapun : Added file: http://bugs.python.org/file19618/test-functools.py ___ Python tracker <http://bugs.python.org/issue6083> ___ ___ Python-bugs-list m

[issue11244] Negative tuple elements produce inefficient code.

2011-03-10 Thread Eugene Toder
Eugene Toder added the comment: As discussed on the list, peephole refuses to fold -0. The reasons for this are unclear. Folding was disabled with this commit: http://hg.python.org/cpython/diff/660419bdb4ae/Python/compile.c Here's a trivial patch to enable the folding again, along with a

[issue11462] Peephole creates duplicate and unused constants

2011-03-10 Thread Eugene Toder
New submission from Eugene Toder : Peephole optimizer performs constant folding, however 1) When it replaces operation with LOAD_CONST it always adds a new constant to co_consts, even if constant with the same value is already there. It also can add the same constant multiple times. 2) It does

[issue11462] Peephole creates duplicate and unused constants

2011-03-10 Thread Eugene Toder
Changes by Eugene Toder : -- keywords: +patch Added file: http://bugs.python.org/file21074/dedup_const_plana.patch ___ Python tracker <http://bugs.python.org/issue11

[issue11462] Peephole creates duplicate and unused constants

2011-03-10 Thread Eugene Toder
Eugene Toder added the comment: (either plana or planb should be applied) -- Added file: http://bugs.python.org/file21075/dedup_const_planb.patch ___ Python tracker <http://bugs.python.org/issue11

[issue11462] Peephole creates duplicate and unused constants

2011-03-10 Thread Eugene Toder
Changes by Eugene Toder : Added file: http://bugs.python.org/file21076/unused_consts.patch ___ Python tracker <http://bugs.python.org/issue11462> ___ ___ Python-bug

[issue11462] Peephole creates duplicate and unused constants

2011-03-10 Thread Eugene Toder
Eugene Toder added the comment: (test case) -- nosy: +pitrou Added file: http://bugs.python.org/file21077/consts_test.patch ___ Python tracker <http://bugs.python.org/issue11

[issue11462] Peephole creates duplicate and unused constants

2011-03-10 Thread Eugene Toder
Eugene Toder added the comment: I think the changes are fairly trivial. dedup_const_planb.patch is about 10 lines of new code with all the rest being trivial plubming. unused_consts.patch may look big, but only because I factored out fix ups into a separate function; there are only about 25

[issue11462] Peephole creates duplicate and unused constants

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: Antoine, sure, I'll fix it with any other suggested changes if patches will be accepted. -- ___ Python tracker <http://bugs.python.org/is

[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: Mark, looks better now? -- Added file: http://bugs.python.org/file21082/fold-0.patch ___ Python tracker <http://bugs.python.org/issue11

[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Eugene Toder
Changes by Eugene Toder : Removed file: http://bugs.python.org/file21082/fold-0.patch ___ Python tracker <http://bugs.python.org/issue11244> ___ ___ Python-bugs-list m

[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: (forgot parens around 0) -- Added file: http://bugs.python.org/file21083/fold-0.2.patch ___ Python tracker <http://bugs.python.org/issue11

[issue11462] Peephole creates duplicate and unused constants

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: > - why the "#ifndef NDEBUG" path? These entries in the table should not be used, but if something slips through and uses one of them, it's much easier to tell if we remap to invalid value. As this is an internal check, I didn't want it i

[issue11462] Peephole creates duplicate and unused constants

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: assert() doesn't quite work here. I need to check that this entry in the table is not used in the next loop. I'd need to put assert in that loop, but by that time I have no easy way to tell which entries are bad, unless I mark them in the first loop.

[issue11462] Peephole creates duplicate and unused constants

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: > _PyCode_AddObj() should be added to Include/code.h Should it be declared as PyAPI_FUNC too? This will make it unnecessarily exported (when patch in Issue11410 is merged), so I wanted to avoid that. btw, that you for reviewing the pa

[issue11462] Peephole creates duplicate and unused constants

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: > Right now, the pattern is tokenize -> parse -> AST -> genbytecode -> > peephole optimization (which disassembles the bytecode, analyzed it > and rewrites it) -> final bytecode. The correct pattern is tokenize > -> parse -&g

[issue11471] If without else generates redundant jump

2011-03-11 Thread Eugene Toder
New submission from Eugene Toder : If statement without else part generates unnecessary JUMP_FORWARD insn with jumps right to the next insn: >>> def foo(x): if x: x = 1 >>> dis(foo) 2 0 LOAD_FAST0 (x) 3 POP_JUMP

[issue11471] If without else generates redundant jump

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: Test case (needed some refactoring to avoid duplication). -- Added file: http://bugs.python.org/file21092/if_no_else_test.patch ___ Python tracker <http://bugs.python.org/issue11

[issue11462] Peephole creates duplicate and unused constants

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: Thomas, can you clarify, does loading interns all constants in co_consts, or do you mean that they are mostly small numbers and the like? Without interning I think that in-memory size difference is even bigger than on-disk, as you get one entry in tuple and

[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: Yes, my patch doesn't fix the regression, only a special case of -0. -- ___ Python tracker <http://bugs.python.org/is

[issue11462] Peephole creates duplicate and unused constants

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: Alexander, my patch does 2 optimizations: doesn't insert a new constant if one already exist and removes unused constants after peephole is done. You patch seems to do only the latter. It's very similar, from a quick look at your patch: - My pat

[issue11462] Peephole creates duplicate and unused constants

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: Raymond, you can be assured that I'm not developing this patch, unless I'm told it has chances to be accepted. I don't like to waste my time. On a related note, your review of my other patches

[issue6981] locale.getdefaultlocale() envvars default code and documentation mismatch

2011-03-12 Thread Eugene Crosser
Eugene Crosser added the comment: I don't know if the solution suggested in the report is right, but I can confirm the the current logic of getdefaultlocale() produces wrong results. I have LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_CTYPE=ru_RU.UTF-8 LC_COLLATE=ru_RU.UTF-8 which

[issue6981] locale.getdefaultlocale() envvars default code and documentation mismatch

2011-03-12 Thread Eugene Crosser
Eugene Crosser added the comment: Steffen: can you please be more specific? As I read the seciton 8.2 of the cited document, I do not see a disparity with my statement. There is even an example: """ For example, if a user wanted to interact with the system in French, but r

[issue11510] Peephole breaks set unpacking

2011-03-14 Thread Eugene Toder
New submission from Eugene Toder : Since the time 'x in set' optimization was added to peephole it has the following bug with set unpacking: >>> def foo(x,y): a,b = {x,y} return a,b >>> dis(foo) 2 0 LOAD_FAST0 (x

[issue11549] Rewrite peephole to work on AST

2011-03-14 Thread Eugene Toder
New submission from Eugene Toder : As pointed out by Raymond, constant folding should be done on AST rather than on generated bytecode. Here's a patch to do that. It's rather long, so overview first. The patch replaces existing peephole pass with a folding pass on AST and a few

[issue11549] Rewrite peephole to work on AST

2011-03-14 Thread Eugene Toder
Changes by Eugene Toder : -- keywords: +patch Added file: http://bugs.python.org/file21198/0_ast.patch ___ Python tracker <http://bugs.python.org/issue11

[issue11549] Rewrite peephole to work on AST

2011-03-14 Thread Eugene Toder
Changes by Eugene Toder : Added file: http://bugs.python.org/file21199/0_fold.patch ___ Python tracker <http://bugs.python.org/issue11549> ___ ___ Python-bugs-list mailin

[issue11549] Rewrite peephole to work on AST

2011-03-14 Thread Eugene Toder
Changes by Eugene Toder : Added file: http://bugs.python.org/file21200/0_compile.patch ___ Python tracker <http://bugs.python.org/issue11549> ___ ___ Python-bugs-list m

[issue11549] Rewrite peephole to work on AST

2011-03-14 Thread Eugene Toder
Changes by Eugene Toder : Added file: http://bugs.python.org/file21201/0_generated.patch ___ Python tracker <http://bugs.python.org/issue11549> ___ ___ Python-bugs-list m

[issue11549] Rewrite peephole to work on AST

2011-03-14 Thread Eugene Toder
Changes by Eugene Toder : Added file: http://bugs.python.org/file21202/0_tests.patch ___ Python tracker <http://bugs.python.org/issue11549> ___ ___ Python-bugs-list mailin

[issue11549] Rewrite peephole to work on AST

2011-03-14 Thread Eugene Toder
Changes by Eugene Toder : -- nosy: +pitrou, rhettinger ___ Python tracker <http://bugs.python.org/issue11549> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue11244] Negative tuple elements produce inefficient code.

2011-03-15 Thread Eugene Toder
Eugene Toder added the comment: Is anyone reviewing my patch? It's just 1 line long. Should it be moved to another issue? Though, technically, it's needed to address the regression in question: Python 3.1 folds -0, the current code stil

[issue11549] Rewrite peephole to work on AST

2011-03-15 Thread Eugene Toder
Eugene Toder added the comment: Because I don't know how to make them. Any pointers? -- ___ Python tracker <http://bugs.python.org/issue11549> ___ ___ Pytho

[issue11549] Rewrite peephole to work on AST

2011-03-15 Thread Eugene Toder
Eugene Toder added the comment: Thanks. Review link: http://codereview.appspot.com/4281051 -- ___ Python tracker <http://bugs.python.org/issue11549> ___ ___ Pytho

[issue11549] Rewrite peephole to work on AST

2011-03-15 Thread Eugene Toder
Eugene Toder added the comment: I see. Should I attach diffs vs. some revision from hg.python.org? -- ___ Python tracker <http://bugs.python.org/issue11

[issue11549] Rewrite peephole to work on AST

2011-03-16 Thread Eugene Toder
Eugene Toder added the comment: Any comments on the code so far or suggestions on how we should move forward? -- ___ Python tracker <http://bugs.python.org/issue11

[issue11549] Rewrite peephole to work on AST

2011-03-16 Thread Eugene Toder
Eugene Toder added the comment: I've updated patches on Rietveld with some small changes. This includes better code generation for boolops used outside of conditions and cleaned up optimize_jumps(). This is probably the last change before I get some feedback. Also, I forgot to me

[issue11549] Rewrite peephole to work on AST

2011-03-16 Thread Eugene Toder
Eugene Toder added the comment: Just for fun I've run pystones. W/o my changes it averages to about 70k, with my changes to about 72.5k. -- ___ Python tracker <http://bugs.python.org/is

[issue11549] Rewrite peephole to work on AST

2011-03-18 Thread Eugene Toder
Eugene Toder added the comment: AFAICT my patch has everything that #1346238 has, except BoolOps, which can be easily added (there's a TODO). I don't want to add any new code, though, until the current patch will get reviewed -- adding code will only make reviewing harder. #1

[issue11549] Rewrite peephole to work on AST

2011-03-23 Thread Eugene Toder
Eugene Toder added the comment: Is anyone looking or planing to look at the patch? -- ___ Python tracker <http://bugs.python.org/issue11549> ___ ___ Python-bug

[issue11549] Rewrite peephole to work on AST

2011-03-27 Thread Eugene Toder
Eugene Toder added the comment: Thanks. > string concatenation will now work, and errors like "'hello' - 'world'" > should give a more informative TypeError Yes, 'x'*5 works too. > Bikeshed: We use Attribute rather than Attr for that node

[issue11549] Rewrite peephole to work on AST

2011-03-27 Thread Eugene Toder
Eugene Toder added the comment: > and with __future__ it should work on 2.5 as well. Actually, seems that at least str.format is not in 2.5 as well. Still the question is should I make it run on 2.5 or 2.4 or is 2.6 OK (then __future__ can be remo

[issue11549] Rewrite peephole to work on AST

2011-03-27 Thread Eugene Toder
Eugene Toder added the comment: > I don't think it can: That already doesn't work in dict and set (eq not consistent with hash), I don't think it's a big problem if that stops working in some other cases. Anyway, I said "theoretically" -- maybe after

[issue11549] Rewrite peephole to work on AST

2011-03-27 Thread Eugene Toder
Eugene Toder added the comment: Also, to avoid any confusion -- currently my patch only runs AST optimizations before code generation, so compile() with ast.PyCF_ONLY_AST returns non-optimized AST. -- ___ Python tracker <http://bugs.python.

[issue11549] Rewrite peephole to work on AST

2011-03-28 Thread Eugene Toder
Eugene Toder added the comment: If we have to preserve backward compatibility of Python AST API, we can do this relatively easily (at the expense of some code complexity): * Add 'version' argument to compile() and ast.parse() with default value of 1 (old AST). Value 2 will corresp

[issue11816] Add functions to return disassembly as string

2011-04-09 Thread Eugene Toder
New submission from Eugene Toder : As discussed in Issue11549 a couple of tests need to inspect disassembly of some code. Currently they have to override sys.stdout, run dis and restore stdout back. It would be much nicer if dis module provided functions that return disassembly as a string

[issue11816] Add functions to return disassembly as string

2011-04-09 Thread Eugene Toder
Changes by Eugene Toder : Removed file: http://bugs.python.org/file21598/dis.diff ___ Python tracker <http://bugs.python.org/issue11816> ___ ___ Python-bugs-list mailin

[issue11816] Add functions to return disassembly as string

2011-04-09 Thread Eugene Toder
Changes by Eugene Toder : Added file: http://bugs.python.org/file21599/dis.patch ___ Python tracker <http://bugs.python.org/issue11816> ___ ___ Python-bugs-list mailin

[issue11816] Add functions to return disassembly as string

2011-04-09 Thread Eugene Toder
Changes by Eugene Toder : -- nosy: +ncoghlan ___ Python tracker <http://bugs.python.org/issue11816> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue11816] Add functions to return disassembly as string

2011-04-09 Thread Eugene Toder
Eugene Toder added the comment: Agreed, but that would require rewriting of all tests in test_peepholer. -- ___ Python tracker <http://bugs.python.org/issue11

[issue5996] abstract class instantiable when subclassing dict

2011-04-09 Thread Eugene Toder
Eugene Toder added the comment: This patch fixes the problem by moving the check from object_new to PyType_GenericAlloc. The check is very cheap, so this should not be an issue. -- keywords: +patch nosy: +eltoder Added file: http://bugs.python.org/file21600/abc.patch

[issue11816] Refactor the dis module to provide better building blocks for bytecode analysis

2011-04-10 Thread Eugene Toder
Eugene Toder added the comment: So in the near term, dis-based tests should continue to copy/paste sys.stdout redirection code? -- ___ Python tracker <http://bugs.python.org/issue11

[issue11983] Inconsistent hash and comparison for code objects

2011-05-02 Thread Eugene Toder
New submission from Eugene Toder : A comment in the definition of PyCodeObject in Include/code.h says: /* The rest doesn't count for hash or comparisons */ which, I think, makes a lot of sense. The implementation doesn't follow this comment, though. code_hash actually includes c

[issue11983] Inconsistent hash and comparison for code objects

2011-05-06 Thread Eugene Toder
Eugene Toder added the comment: I would propose changing implementation to match the comment. At a minimum, remove co_firstlineno comparison. As the last resort, at least change the comment. -- ___ Python tracker <http://bugs.python.

[issue11983] Inconsistent hash and comparison for code objects

2011-05-08 Thread Eugene Toder
Eugene Toder added the comment: It appears that * co_name was added to hash and cmp in this check-in by Guido: http://hg.python.org/cpython-fullhistory/diff/525b2358721e/Python/compile.c I think the reason was to preserve function name when defining multiple functions with the same code in

[issue11983] Inconsistent hash and comparison for code objects

2011-05-08 Thread Eugene Toder
Eugene Toder added the comment: Btw, disabling dedup for codes won't be the first exception -- we already avoid coalescing -0.0 with 0.0 for float and complex, even though they compare equal. -- ___ Python tracker <http://bugs.py

[issue11262] re.sub replaces only first 32 matches with re.U flag

2011-02-20 Thread Eugene Morozov
New submission from Eugene Morozov : There's a peculiar and difficult to find bug in the re.sub method. Try following example: >>> text = 'X'*4096 >>> nt = re.sub(u"XX", u".", text, re.U) >>> nt u'XXX

[issue8075] Windows (Vista/7) install error when choosing to compile .py files

2010-03-05 Thread Eugene Baranov
New submission from Eugene Baranov : I tried installing Python 2.6.4 into Program Files in Windows 7 and choose to compile .py files after install. Installer correctly asks for a elevation and copies all fixes but it looks like compile batch are being started from initial, unelevated context

[issue8401] Strange behavior of bytearray slice assignment

2010-04-14 Thread Eugene Kapun
New submission from Eugene Kapun : >>> a = bytearray() >>> a[:] = 0 # Is it a feature? >>> a bytearray(b'') >>> a[:] = 10 # If so, why not document it? >>> a bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') >>> a[:]

[issue8401] Strange behavior of bytearray slice assignment

2010-04-16 Thread Eugene Kapun
Eugene Kapun added the comment: Empty string is an iterable of integers in the range 0 <= x < 256, so it should be allowed. >>> all(isinstance(x, int) and 0 <= x < 256 for x in "") True >>> bytearray()[:] = "" Traceback (most recent ca

[issue8417] bytes and bytearray constructors raise TypeError for very large ints

2010-04-16 Thread Eugene Kapun
New submission from Eugene Kapun : >>> bytes(10) b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' >>> bytes(10 ** 100) Traceback (most recent call last): File "", line 1, in TypeError: 'int' object is not iterable -- components: Interpr

[issue1766304] improve xrange.__contains__

2010-04-16 Thread Eugene Kapun
Changes by Eugene Kapun : -- nosy: +abacabadabacaba ___ Python tracker <http://bugs.python.org/issue1766304> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue8401] Strange behavior of bytearray slice assignment

2010-04-16 Thread Eugene Kapun
Eugene Kapun added the comment: > Not really, chars are not ints Yes, however, empty string contains exactly zero chars. > and anyway the empty string fall in the first case. Strings aren't mentioned in documentation of bytearray slice assignment. However, I think that bytearray

[issue8401] Strange behavior of bytearray slice assignment

2010-04-16 Thread Eugene Kapun
Eugene Kapun added the comment: __doc__ of bytearray says: > bytearray(iterable_of_ints) -> bytearray > bytearray(string, encoding[, errors]) -> bytearray > bytearray(bytes_or_bytearray) -> mutable copy of bytes_or_bytearray > bytearray(memory_view) -> bytearray So, unl

[issue8420] set_lookkey is unsafe

2010-04-16 Thread Eugene Kapun
New submission from Eugene Kapun : I've noticed that set_lookkey (in Objects/setobject.c) does some unsafe things: Objects/setobject.c: > if (entry->hash == hash) { > startkey = entry->key; > Py_INCREF(startkey); > cmp = PyObject_RichCompareBo

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

2010-04-16 Thread Eugene Kapun
New submission from Eugene Kapun : >>> small_set = set(range(2000)) >>> large_set = set(range(2000)) >>> large_set -= small_set # Fast >>> small_set -= large_set # Slow, should be fast >>> small_set = small_set - large_set # Fast -- compo

[issue8401] Strange behavior of bytearray slice assignment

2010-04-17 Thread Eugene Kapun
Eugene Kapun added the comment: -1 on special-casing string without an encoding. Current code does (almost) this: ... if argument_is_a_string: if not encoding_is_given: # Special case raise TypeError("string argument without an encoding") encod

[issue8420] Objects/setobject.c contains unsafe code

2010-04-17 Thread Eugene Kapun
Eugene Kapun added the comment: I've found more unsafe code in Objects/setobject.c. This code makes Python 3.1.2 segfault by using a bug in function set_merge: class bad: def __eq__(self, other): if be_bad: set2.

[issue8435] It is possible to observe a mutating frozenset

2010-04-17 Thread Eugene Kapun
New submission from Eugene Kapun : This code shows that frozensets aren't really immutable. The same frozenset is printed twice, with different content. Buggy functions are set_contains, set_remove and set_discard, all in Objects/setobject.c class bad: def __eq__(self,

[issue8420] Objects/setobject.c contains unsafe code

2010-04-17 Thread Eugene Kapun
Changes by Eugene Kapun : -- type: -> crash ___ Python tracker <http://bugs.python.org/issue8420> ___ ___ Python-bugs-list mailing list Unsubscri

[issue8436] set.__init__ accepts keyword args

2010-04-17 Thread Eugene Kapun
New submission from Eugene Kapun : >>> list().__init__(a=0) Traceback (most recent call last): File "", line 1, in TypeError: 'a' is an invalid keyword argument for this function >>> set().__init__(a=0) -- components: Interpreter Core messages:

[issue8420] Objects/setobject.c contains unsafe code

2010-04-18 Thread Eugene Kapun
Eugene Kapun added the comment: This patch still assumes that if so->table didn't change then the table wasn't reallocated (see http://en.wikipedia.org/wiki/ABA_problem). One solution is to check that so->mask didn't change as well. Also, checking that refcnt > 1

[issue8420] Objects/setobject.c contains unsafe code

2010-04-18 Thread Eugene Kapun
Eugene Kapun added the comment: > > One solution is to check that so->mask didn't > > change as well. > > I saw that and agree it would make a tighter check, but haven't convinced > myself that it is necessary. Without this check, it is possible that th

[issue8420] Objects/setobject.c contains unsafe code

2010-04-18 Thread Eugene Kapun
Eugene Kapun added the comment: This code crashes python by using another bug in set_repr. This only affects py3k. This code relies on out-of-memory condition, so run it like: $ (ulimit -v 65536 && python3 test.py) Otherwise, it will eat all your free memory before crashing. val = &qu

[issue8420] Objects/setobject.c contains unsafe code

2010-04-18 Thread Eugene Kapun
Changes by Eugene Kapun : Added file: http://bugs.python.org/file16981/repr.diff ___ Python tracker <http://bugs.python.org/issue8420> ___ ___ Python-bugs-list mailin

[issue44018] Bug in random.seed

2021-05-03 Thread Eugene Rossokha
New submission from Eugene Rossokha : https://github.com/python/cpython/blob/master/Lib/random.py#L157 If bytearray is passed as a seed, the function will change it. It either has to be documented, or the implementation should change. -- components: Library (Lib) messages: 392782 nosy

[issue44018] Bug in random.seed

2021-05-03 Thread Eugene Rossokha
Eugene Rossokha added the comment: I find the following behaviour very confusing: >>> import random >>> a = bytearray("1234", "utf-8") >>> b = bytearray("1234", "utf-8") >>> a == b True >>> random.seed(a) >

[issue42125] linecache cannot get source for the __main__ module with a custom loader

2020-12-15 Thread Eugene Toder
Change by Eugene Toder : -- nosy: +brett.cannon ___ Python tracker <https://bugs.python.org/issue42125> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42125] linecache cannot get source for the __main__ module with a custom loader

2020-12-18 Thread Eugene Toder
Change by Eugene Toder : -- nosy: +ncoghlan, vstinner ___ Python tracker <https://bugs.python.org/issue42125> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42903] optimize lru_cache for functions with no arguments

2021-01-11 Thread Eugene Toder
New submission from Eugene Toder : It's convenient to use @lru_cache on functions with no arguments to delay doing some work until the first time it is needed. Since @lru_cache is implemented in C, it is already faster than manually caching in a closure variable. However, it can be made

[issue42903] optimize lru_cache for functions with no arguments

2021-01-11 Thread Eugene Toder
Eugene Toder added the comment: As you can see in my original post, the difference between @cache (aka @lru_cache(None)) and just @lru_cache() is negligible in this case. The optimization in this PR makes a much bigger difference. At the expense of some lines of code, that's true.

[issue42903] optimize lru_cache for functions with no arguments

2021-01-11 Thread Eugene Toder
Eugene Toder added the comment: Ammar, thank you for the link. -- ___ Python tracker <https://bugs.python.org/issue42903> ___ ___ Python-bugs-list mailin

[issue42903] optimize lru_cache for functions with no arguments

2021-01-12 Thread Eugene Toder
Eugene Toder added the comment: @cache does not address the problem or any of the concerns brought up in the thread. Thread-safe @once is a nice idea, but more work of course. -- ___ Python tracker <https://bugs.python.org/issue42

[issue40962] Add documentation for asyncio._set_running_loop()

2020-06-12 Thread Eugene Huang
New submission from Eugene Huang : In the pull request https://github.com/python/asyncio/pull/452#issue-92245081 the linked comment says that `asyncio._set_running_loop()` is part of the public asyncio API and will be documented, but I couldn't find any references to this functi

[issue42125] linecache cannot get source for the __main__ module with a custom loader

2020-10-22 Thread Eugene Toder
New submission from Eugene Toder : If a module has a loader, linecache calls its get_source() passing __name__ as the argument. This works most of the time, except that the __main__ module has it set to "__main__", which is commonly not the real name of the module. Luckily, w

[issue1065427] sre_parse group limit check missing with 'python -O'

2012-08-20 Thread Eugene Voytitsky
Eugene Voytitsky added the comment: Hi all, does someone can answer the questions asked by Keith Briggs in 2004: > What is the reason for this limit? Can it easily be removed? > It is causing me many problems. I also stuck into the problem with this limitation. Details you can rea

[issue11549] Build-out an AST optimizer, moving some functionality out of the peephole optimizer

2012-09-05 Thread Eugene Toder
Eugene Toder added the comment: > Method calls on literals are always fair game, though (e.g. you could > optimise "a b c".split()) What about optimizations that do not change behavior, except for different error messages? E.g. we can change y = [1,2][x] to y = (1,2)[x] wh

[issue11549] Build-out an AST optimizer, moving some functionality out of the peephole optimizer

2012-09-05 Thread Eugene Toder
Eugene Toder added the comment: If I'm not missing something, changing x in [1,2] to x in (1,2) and x in {1,2} to x in frozenset([1,2]) does not change any error messages. Agreed that without dynamic compilation we can pretty much only track literals (including functions and lambdas) ass

  1   2   >