[issue18078] threading.Condition to allow notify on a specific waiter

2019-01-23 Thread João Bernardo
João Bernardo added the comment: Don't keep your hopes up. People here don't like implementing features they don't understand about even if they could verify elsewhere it works well. My solution at the time was to create a decent "Condition" class based on the original one (s

[issue13290] get vars for object with __slots__

2017-04-05 Thread João Bernardo
João Bernardo added the comment: Being the OP, at that time I felt it was important to have a vars() function that worked on __slots__ to ease something I was developing. The truth for me is: __slots__ is not really relevant anymore. The benefits it brings are not enough to make the feature

[issue18159] ConfigParser getters not available on SectionProxy

2014-04-17 Thread João Bernardo
João Bernardo added the comment: ping? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18159 ___ ___ Python-bugs-list mailing list Unsubscribe

[issue19933] Round default argument for ndigits

2013-12-09 Thread João Bernardo
João Bernardo added the comment: I don't understand. There's already a way to make round return an integer: don't pass a second argument. If this function were to be written in Python, it would be something like: def round(number, ndigits=0): ... or def round(number

[issue19933] Round default argument for ndigits

2013-12-09 Thread João Bernardo
João Bernardo added the comment: Anyway, why not round(1.2) - 1.0 in the first place? Just curious. It was the behavior on Python 2.x, but somehow when they changed the rounding method to nearest even number this happened... I think it's too late to change back the return type

[issue19933] Round default argument for ndigits

2013-12-09 Thread João Bernardo
João Bernardo added the comment: Not really. Just consistency: For the same reason ' foo '.strip(None) works... To avoid special casing the function call when you already have a variable to hold the argument. -- ___ Python tracker rep

[issue19933] Round default argument for ndigits

2013-12-08 Thread João Bernardo
New submission from João Bernardo: From the docs for built-in function round: If ndigits is omitted, it defaults to zero (http://docs.python.org/3/library/functions.html#round) But, the only way to get an integer from `round` is by not having the second argument (ndigits): round

[issue18078] threading.Condition to allow notify on a specific waiter

2013-08-05 Thread João Bernardo
João Bernardo added the comment: Seems like just because I never used I don't support. Boost C++ libraries has a wait_for_any functionality to synchronize futures. C# has a WaitAny in the WaitHandle class (like our Condition). Another problem is: the Condition class cannot be easily

[issue18078] threading.Condition to allow notify on a specific waiter

2013-08-04 Thread João Bernardo
João Bernardo added the comment: I've been thinking about returning a list on wait_for_any, but that way you will not be able to implement wait_for using it! wait_for will return False on timeouts while wait_for_any will return a list with some conditions(evaluates to True). Also, wait_for

[issue18078] threading.Condition to allow notify on a specific waiter

2013-07-24 Thread João Bernardo
João Bernardo added the comment: ping. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18078 ___ ___ Python-bugs-list mailing list Unsubscribe

[issue18078] threading.Condition to allow notify on a specific waiter

2013-07-24 Thread João Bernardo
João Bernardo added the comment: Charles-François's point about the algorithmic complexity is legitimate, so I think he was actually waiting for you to amend your patch ;) This doesn't seems to be the actual issue as it would require a big change for something that wasn't proven important

[issue18078] threading.Condition to allow notify on a specific waiter

2013-07-24 Thread João Bernardo
João Bernardo added the comment: 1) It should check all predicates. OK. Maybe later there could be an option for customization? 2) It should return a list of ready conditions. OK. 3) It should *not* accept a list of conditions. The list option would be to simplify the wait method

[issue18159] ConfigParser getters not available on SectionProxy

2013-07-16 Thread João Bernardo
João Bernardo added the comment: Was the patch accepted yet? Looks good to me -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18159

[issue18078] threading.Condition to allow notify on a specific waiter

2013-06-19 Thread João Bernardo
João Bernardo added the comment: (ping) It would be nice to have the feature on 3.4. What changes should I do to the patch? Is anyone else working on that? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18078

[issue18159] ConfigParser getters not available on SectionProxy

2013-06-08 Thread João Bernardo
João Bernardo added the comment: Overriding __getattr__ doesn't look like the best solution Another idea would be to allow the proxy class to be selectable, but this would require the user to do much more coding for this simple thing... I believe a proxy should be dynamic enough to avoid

[issue18159] ConfigParser getters not available on SectionProxy

2013-06-07 Thread João Bernardo
New submission from João Bernardo: The configparser.RawConfigParser class implements some `get` methods: get, getint, getfloat, getboolean but if any of these get overridden on a subclass(with other arguments) or new ones are added (e.g. getlist), there's no way a SectionProxy instance

[issue18078] threading.Condition to allow notify on a specific waiter

2013-06-04 Thread João Bernardo
João Bernardo added the comment: I'm not convinced it's really useful. It doesn't seem a lot useful until you *really* need it. I've got 2 highly parallel programs that took advantage of this pattern. the wait is O(C) (appending to C wait queues) and wakeup is O(CT) (C removal from a T

[issue18078] threading.Condition to allow notify on a specific waiter

2013-06-04 Thread João Bernardo
João Bernardo added the comment: BTW, I think it would be better to have wait_for_any() return a list of ready conditions rather than a boolean. That was the original idea until I realized `wait` and `wait_for` were just specializations of `wait_for_any`. This can probably be done

[issue18078] threading.Condition to allow notify on a specific waiter

2013-06-04 Thread João Bernardo
João Bernardo added the comment: Here, removing a thread from a wait queue other than the one from which it was signalled is O(waiting threads). To be fair, You will probably never have more than a few hundred/thousand threads on a process. Usually you'll work under a few dozen threads

[issue18078] threading.Condition to allow notify on a specific waiter

2013-06-03 Thread João Bernardo
João Bernardo added the comment: Hi, This code is working quite well on my system, but I'm still not sure if the behavior of multiple predicates is the one other people want. So, for the thread start running again: - Should it test only the predicates from the awakened Conditions an accept

[issue18078] threading.Condition to allow notify on a specific waiter

2013-05-29 Thread João Bernardo
João Bernardo added the comment: I did what @Richard Oudkerk said and created the wait_for_any classmethod for the Condition class. Other Changes: - I had to refactor wait and wait_for to be specializations of wait_for_any. - try...except on notify because the inner lock might have been

[issue18078] threading.Condition to allow notify on a specific waiter

2013-05-28 Thread João Bernardo
João Bernardo added the comment: I usually have hundreds of threads waiting on a single Condition object and I wake them with .notify_all() Sometimes, I want a specific thread to wake from this condition and finish their job apart from the others. The problem is that I have 2 conditions

[issue18078] threading.Condition to allow notify on a specific waiter

2013-05-28 Thread João Bernardo
João Bernardo added the comment: But it might be nice to be able to wait on multiple conditions at once, assuming they are associated with the same lock. Maybe we could have a static method This could solve the waiting problem for the thread, but also may keep the other Condition objs

[issue18078] threading.Condition to allow notify on a specific waiter

2013-05-28 Thread João Bernardo
João Bernardo added the comment: It would be for waiting for several conditions associated with the same lock, not for waiting for several locks. A Condition uses a 2 lock mechanism: - outer lock: one for all the waiters to access the Condition object - inner lock: one for each waiter

[issue18078] threading.Condition to allow notify on a specific waiter

2013-05-28 Thread João Bernardo
João Bernardo added the comment: Condition.wait_for_any() would create a single inner lock and add it to the _waiters list for each of the condition variables Now I see your point! Could it also have one (optional) argument so I can provide this lock myself? while expr

[issue18078] threading.Condition to allow notify on a specific waiter

2013-05-27 Thread João Bernardo
New submission from João Bernardo: If users could provide an inner lock for `threading.Condition` acquire when making a thread wait, it would allow for notifying a specific waiter. Because of race conditions, using: cond.notify(1) may not wake the thread I want. Also, I may not want

[issue16872] Metaclass conflict proposition

2013-01-05 Thread João Bernardo
New submission from João Bernardo: This is actually a proposition for a behavior change caused by a bugfix. I have a project dealing with a metaclass factory and the next thing in the TODO list was to add multiple inheritance support. For my surprise, I tried and there was no metaclass

[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread João Bernardo
João Bernardo jbv...@gmail.com added the comment: Of course `nan` and `inf` are part of the syntax! The `ast.parse` function recognize them as `Name`. So that works: ast.dump(ast.parse('True')) Module(body=[Expr(value=Name(id='True', ctx=Load()))]) ast.dump(ast.parse('inf')) Module(body

[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread João Bernardo
Changes by João Bernardo jbv...@gmail.com: -- keywords: +patch Added file: http://bugs.python.org/file26262/ast.py.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15245

[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread João Bernardo
João Bernardo jbv...@gmail.com added the comment: Ellipsis in this context is `_ast.Ellipsis`, not the original one... There's no TypeError there as `_ast.Ellipsis` is a class. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread João Bernardo
Changes by João Bernardo jbv...@gmail.com: Added file: http://bugs.python.org/file26264/ast.py_with_tests.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15245

[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread João Bernardo
João Bernardo jbv...@gmail.com added the comment: Just to be sure: What's a doc update? The `.rst` files are updated automatically with the doc strings? The adding another argument should require a: Changed in version 3.x: Accepts a second argument

[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread João Bernardo
Changes by João Bernardo jbv...@gmail.com: Added file: http://bugs.python.org/file26266/ast.py_tests_doc.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15245

[issue15245] ast.literal_eval fails on some literals

2012-07-04 Thread João Bernardo
João Bernardo jbv...@gmail.com added the comment: That's what I said by `nan` and `inf` are not literals, but their representations look like they should be. One solution could be to add another argument to allow some extra names. Maybe a mapping, as `eval

[issue15245] ast.literal_eval on some literals

2012-07-03 Thread João Bernardo
New submission from João Bernardo jbv...@gmail.com: `ast.literal_eval` is very strict on names, so it seems to lack some literals that may be result of `repr` on built-in objects. - Obvious cases: ast.literal_eval('...') ast.literal_eval('Ellipsis') both result on ValueError. - Not so

[issue13667] __contains__ method behavior

2011-12-28 Thread João Bernardo
New submission from João Bernardo jbv...@gmail.com: Hi, I'm working on a class which implements the __contains__ method but the way I would like it to work is by generating an object that will be evaluated later. It'll return a custom object instead of True/False class C: def

[issue13667] __contains__ method behavior

2011-12-28 Thread João Bernardo
João Bernardo jbv...@gmail.com added the comment: @Georg Brandl Oh sorry, now I see... true != True But still, why is that the default behavior? Shouldn't it use whatever the method returns? -- type: enhancement - behavior versions: +Python 3.2

[issue13667] __contains__ method behavior

2011-12-28 Thread João Bernardo
Changes by João Bernardo jbv...@gmail.com: -- type: behavior - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13667 ___ ___ Python-bugs

[issue13667] __contains__ method behavior

2011-12-28 Thread João Bernardo
João Bernardo jbv...@gmail.com added the comment: I see that every other comparison operator (, , =, =, ==, !=) except for `is` work the way I expect and is able to return anything. e.g. numpy.arange(5) 3 array([ True, True, True, False, False], dtype=bool) I didn't checked the code

[issue13667] __contains__ method behavior

2011-12-28 Thread João Bernardo
João Bernardo jbv...@gmail.com added the comment: Using my poor grep abilities I found that on Objects/typeobject.c (I replaced some declarations/error checking from the code with ...) static int slot_sq_contains(PyObject *self, PyObject *value) { ... func = lookup_maybe(self

[issue13667] __contains__ method behavior

2011-12-28 Thread João Bernardo
João Bernardo jbv...@gmail.com added the comment: The problem with `not in` is because it must evaluate the result. It's not just another operator like == and !=. Looks like we're suffering from premature optimization and now it would break a lot of code to make it good. For my application

[issue13290] get vars for object with __slots__

2011-11-04 Thread João Bernardo
João Bernardo jbv...@gmail.com added the comment: Oh, sorry for the full file. Yes, I only changed after d = PyObject_GetAttrString(v, __dict__); if (d == NULL) { I was searching for uses of slots other than __slots__ = (a, b) and I saw a guy saying that dicts may have

[issue13290] get vars for object with __slots__

2011-10-29 Thread João Bernardo
New submission from João Bernardo jbv...@gmail.com: I just realized the builtin function `vars` can't handle custom objects without the __dict__ attribute. It would be nice if it worked with objects that have __slots__ to make them look more like normal objects and to make debugging easier

[issue13153] IDLE crash with unicode bigger than 0xFFFF

2011-10-14 Thread João Bernardo
João Bernardo jbv...@gmail.com added the comment: Just for comparison, on Python 2.7.1 (x32 on Windows 7) it's possible to paste the char (but can't use it) and a nice error is given. u'Ң' Unsupported characters in input So the problem was partially solved but something might have happened

[issue13153] IDLE crash with unicode bigger than 0xFFFF

2011-10-14 Thread João Bernardo
João Bernardo jbv...@gmail.com added the comment: Just to complete my monologue: Here's the traceback from running IDLE in cmd line. C:\Python32\Lib\idlelibpython -i idle.py Traceback (most recent call last): File idle.py, line 11, in module idlelib.PyShell.main() File C:\Python32\Lib

[issue13153] IDLE crash with unicode bigger than 0xFFFF

2011-10-11 Thread João Bernardo
New submission from João Bernardo jbv...@gmail.com: I was playing with some unicode chars on Python 3.2 (x64 on Windows 7), but when pasted a char bigger than 0x, IDLE crashes without any error message. Example (works fine): '\U000104a2' 'Ң' But, if I try to paste the above char

[issue13153] IDLE crash with unicode bigger than 0xFFFF

2011-10-11 Thread João Bernardo
João Bernardo jbv...@gmail.com added the comment: @Ned That looks like a bit different case. IDLE *can* print the char after you entered the '\U' version of it. It doesn't accept you to paste those caracters... -- ___ Python tracker rep

[issue12745] Python2 or Python3 page

2011-08-12 Thread João Bernardo
New submission from João Bernardo jbv...@gmail.com: Since 2008 (as far as can remember) the Python Download page has a link to that web page: http://wiki.python.org/moin/Python2orPython3 I know it's been updated but it keeps saying the same thing since Python 3.0 was launched. Basically

[issue12538] Extending int class

2011-07-11 Thread João Bernardo
New submission from João Bernardo jbv...@gmail.com: I'm having trouble subclassing the int type and I think this behavior is a bug... (Python 3.2) class One(int): def __init__(self): super().__init__(1) one = One() one + 2 2 one == 0 True I know `int` objects

[issue12438] IDLE problem displaying warning message

2011-07-03 Thread João Bernardo
João Bernardo jbv...@gmail.com added the comment: @orsenthil My system is Ubuntu 11.04 x64. To run idle, i press the Super (windows button) then write idle. If I open the terminal and type idle, the problem don't appear but I have to type the password on the terminal rather than on idle GUI

[issue12438] getpass error on idle

2011-06-28 Thread João Bernardo
New submission from João Bernardo jbv...@gmail.com: The getpass function is raising an error when first used on idle (Python 3.2 and 2.7.1) The next time it'll work as expected (it echoes the data, but idle is just for testing purposes so no problems here) from getpass import getpass p

[issue11658] complex sqrt error

2011-03-23 Thread João Bernardo
New submission from João Bernardo jbv...@gmail.com: With Python 3, the ** operator is supposed to do math with complex numbers, but look what is happening: Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)] on win32 Type copyright, credits or license() for more