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
origi
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
João Bernardo added the comment:
ping?
--
___
Python tracker
<http://bugs.python.org/issue18159>
___
___
Python-bugs-list mailing list
Unsubscribe:
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 trac
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
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
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 se
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 c
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 w
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 &quo
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
João Bernardo added the comment:
ping.
--
___
Python tracker
<http://bugs.python.org/issue18078>
___
___
Python-bugs-list mailing list
Unsubscribe:
João Bernardo added the comment:
Was the patch accepted yet? Looks good to me
--
___
Python tracker
<http://bugs.python.org/issue18159>
___
___
Python-bugs-list m
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
<http://bugs.python.org/issue18
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
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 ins
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
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 don
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
>
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 acce
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
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?
>
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 fo
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 t
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 "condition
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 to
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
Changes by João Bernardo :
Added file: http://bugs.python.org/file26266/ast.py_tests_doc.diff
___
Python tracker
<http://bugs.python.org/issue15245>
___
___
Python-bug
João Bernardo 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 secon
Changes by João Bernardo :
Added file: http://bugs.python.org/file26264/ast.py_with_tests.diff
___
Python tracker
<http://bugs.python.org/issue15245>
___
___
Python-bug
João Bernardo 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
<http://bugs.python.org/is
Changes by João Bernardo :
--
keywords: +patch
Added file: http://bugs.python.org/file26262/ast.py.diff
___
Python tracker
<http://bugs.python.org/issue15
João Bernardo 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()))])"
>>&g
João Bernardo 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
New submission from João Bernardo :
`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
João Bernardo 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.
F
João Bernardo 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, "__conta
João Bernardo 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
Changes by João Bernardo :
--
type: behavior -> enhancement
___
Python tracker
<http://bugs.python.org/issue13667>
___
___
Python-bugs-list mailing list
Un
João Bernardo 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
___
Python
New submission from João Bernardo :
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 __contains
João Bernardo 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 special m
New submission from João Bernardo :
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.
I change
João Bernardo added the comment:
Just to complete my monologue:
Here's the traceback from running IDLE in cmd line.
C:\Python32\Lib\idlelib>python -i idle.py
Traceback (most recent call last):
File "idle.py", line 11, in
idlelib.PyShell.main()
File "C:\Python32
João Bernardo 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 mi
João Bernardo 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
New submission from João Bernardo :
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 th
New submission from João Bernardo :
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 it says that P
New submission from João Bernardo :
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
>>>
João Bernardo 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 t
New submission from João Bernardo :
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
New submission from João Bernardo :
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 "licens
52 matches
Mail list logo