On 18/03/14 07:52, Maciej Fijalkowski wrote:
Hi
I have a question about calling __eq__ in some cases.
We're thinking about doing an optimization where say:
if x in d:
return d[x]
where d is a dict would result in only one dict lookup (the second one
being constant folded away). The ques
On Tue, Mar 18, 2014 at 11:19 PM, Paul Moore wrote:
> On 18 March 2014 19:46, Maciej Fijalkowski wrote:
>>> A question: how far away will this optimization apply?
>>>
>>> if x in d:
>>> do_this()
>>> do_that()
>>> do_something_else()
>>> spam = d[x]
>>
>> it de
On Tue, 18 Mar 2014 09:52:05 +0200
Maciej Fijalkowski wrote:
>
> We're thinking about doing an optimization where say:
>
> if x in d:
>return d[x]
>
> where d is a dict would result in only one dict lookup (the second one
> being constant folded away). The question is whether it's ok to do
On Wed, Mar 19, 2014 at 2:42 PM, Antoine Pitrou wrote:
> On Tue, 18 Mar 2014 09:52:05 +0200
> Maciej Fijalkowski wrote:
>>
>> We're thinking about doing an optimization where say:
>>
>> if x in d:
>>return d[x]
>>
>> where d is a dict would result in only one dict lookup (the second one
>> be
On 03/18/2014 10:19 PM, Paul Moore wrote:
Surely in the presence of threads the optimisation is invalid anyway
Why? As written, the code uses no synchronization primitives to ensure
that the modifications to the dict are propagated at a particular point.
As a consequence, it cannot rely on th
On Wed, 19 Mar 2014 15:09:04 +0200
Maciej Fijalkowski wrote:
>
> I would like to point out that instructing people does not really
> work. Besides, other examples like this:
>
> if d[x] >= 3:
>d[x] += 1 don't really work.
That's a good point. But then, perhaps PyPy should analyze the __eq__
On Wed, Mar 19, 2014 at 3:17 PM, Antoine Pitrou wrote:
> On Wed, 19 Mar 2014 15:09:04 +0200
> Maciej Fijalkowski wrote:
>>
>> I would like to point out that instructing people does not really
>> work. Besides, other examples like this:
>>
>> if d[x] >= 3:
>>d[x] += 1 don't really work.
>
> Th
On Wed, 19 Mar 2014 15:21:16 +0200
Maciej Fijalkowski wrote:
> On Wed, Mar 19, 2014 at 3:17 PM, Antoine Pitrou wrote:
> > On Wed, 19 Mar 2014 15:09:04 +0200
> > Maciej Fijalkowski wrote:
> >>
> >> I would like to point out that instructing people does not really
> >> work. Besides, other exampl
On Wed, Mar 19, 2014 at 6:26 AM, Antoine Pitrou wrote:
> On Wed, 19 Mar 2014 15:21:16 +0200
> Maciej Fijalkowski wrote:
>
> > On Wed, Mar 19, 2014 at 3:17 PM, Antoine Pitrou
> wrote:
> > > On Wed, 19 Mar 2014 15:09:04 +0200
> > > Maciej Fijalkowski wrote:
> > >>
> > >> I would like to point ou
This mailing list is for the development *of* Python, the the *use* of
Python. Your best option for getting an answer is to ask on python-list or
python-help.
On Tue, Mar 18, 2014 at 9:50 PM, 北冰洋 wrote:
> Dear,
>
> I just wrote a sample like this:
> testPy/
> __init__.py
> cli
On Wed, 19 Mar 2014 07:09:23 -0700
Thomas Wouters wrote:
>
> He means you're being unrealistically pedantic :) The number of calls to
> __eq__ is _already_ unpredictable, since (as Mark Shannon said) it depends
> among other things on the hashing algorithm and the size of the dict.
Well, I was n
The docs don't seem to make any guarantee about calling __eq__ or __hash__:
d[key]
Return the item of d with key key. Raises a KeyError if key is not in the
map.
which seems to indicate that this kind of optimization should be fine.
In fact I would very much like messing with the semantics of __
Am 17.03.14 22:10, schrieb Jurko Gospodnetić:
> Fixing
> this required manually cleaning up leftover CPython 3.4.0rc3 windows
> installer registry entries. Note that the issue could not be fixed by
> using the CPython 3.4.0rc3 installer as it failed due to the same problem.
Did you try the 3.4.0rc
Sorry, I definitely didn't mean to imply that this kind of optimization is
valid on arbitrary subscript expressions; I thought we had restricted
ourselves to talking about builtin dicts. If we do, I think this becomes a
discussion about what subset of the semantics of CPython's builtins are
langua
Hi.
On 19.3.2014. 16:38, "Martin v. Löwis" wrote:
> Am 17.03.14 22:10, schrieb Jurko Gospodnetić:
>> Fixing
>> this required manually cleaning up leftover CPython 3.4.0rc3 windows
>> installer registry entries. Note that the issue could not be fixed
>> by using the CPython 3.4.0rc3 installer as
On Wed, Mar 19, 2014 at 3:26 PM, Antoine Pitrou wrote:
> On Wed, 19 Mar 2014 15:21:16 +0200
> Maciej Fijalkowski wrote:
>
>> On Wed, Mar 19, 2014 at 3:17 PM, Antoine Pitrou wrote:
>> > On Wed, 19 Mar 2014 15:09:04 +0200
>> > Maciej Fijalkowski wrote:
>> >>
>> >> I would like to point out that i
On Wed, Mar 19, 2014 at 8:38 AM, Kevin Modzelewski wrote:
> Sorry, I definitely didn't mean to imply that this kind of optimization is
> valid on arbitrary subscript expressions; I thought we had restricted
> ourselves to talking about builtin dicts. If we do, I think this becomes a
> discussion
Kevin Modzelewski writes:
> Sorry, I definitely didn't mean to imply that this kind of
> optimization is valid on arbitrary subscript expressions; I thought
> we had restricted ourselves to talking about builtin dicts.
Ah, maybe so -- Maciej made that clear later for PyPy. My bad. (With
the
Hi.
> Did you try the 3.4.0rc3 "repair" installation? That should have
> undeleted (repaired) the files that you had manually deleted.
Just tested this out and repairing the same matching installation
does revert the removed files. It does not reinstall pip and setuptools
packages but th
Hi.
On 19.3.2014. 16:38, "Martin v. Löwis" wrote:
Am 17.03.14 22:10, schrieb Jurko Gospodnetić:
Fixing
this required manually cleaning up leftover CPython 3.4.0rc3 windows
installer registry entries. Note that the issue could not be fixed by
using the CPython 3.4.0rc3 installer as it failed d
Code below has been written with the intension of acquiring ONLY one lock.
There are two issues:
1- Sometimes it returns more than one lock in done.
2- Sometimes, even if wait exits with zero or one locks, it seems
there are other locks are acquired too. Though, I couldn't isolate
the exact case f
Hi Imran,
The python-dev list is not the place to ask questions about the usage of
Python modules or features. However, since you are asking an
asyncio-related question, you should be welcome at the python-tulip list:
https://groups.google.com/forum/?fromgroups#!forum/python-tulip
--Guido
On We
Hi.
Should I open a 'Add/Remove Programs' dialog related issue in the
CPython issue tracker?
Please do. It would also good if somebody volunteered to reproduce
the issue.
Opened issue #20984.
http://bugs.python.org/issue20984
Anyone have Windows 8 x64 available to try this out b
Hello,
It is known to be cumbersome to write a proxy type that will correctly
proxy all special methods (this has to be done manually on the type,
since special methods are not looked up on the instance: a __getattr__
method would not work).
Recently we've had reports of two stdlib types that fo
On Wed, 19 Mar 2014 10:53:31 -0700
Ethan Furman wrote:
> I just made a change to some error messages [1] (really, just one):
>
> old behavior:
>
>'%o' % 3.14
>'float' object cannot be interpreted as an integer
>
> new behavior:
>
>'%o' % 3.14
>%o format: an integer is required
I just made a change to some error messages [1] (really, just one):
old behavior:
'%o' % 3.14
'float' object cannot be interpreted as an integer
new behavior:
'%o' % 3.14
%o format: an integer is required, not float
Would we normally add a test for that?
--
~Ethan~
[1] Issue 19995:
Sure, I'll check it this evening.
Jurko Gospodnetić wrote on 03/19/2014 01:41:19
PM:
>
>Hi.
>
> >>Should I open a 'Add/Remove Programs' dialog related issue in the
> >> CPython issue tracker?
> >
> > Please do. It would also good if somebody volunteered to reproduce
> > the issue.
>
>
Am 19.03.2014 19:55, schrieb Antoine Pitrou:
> On Wed, 19 Mar 2014 10:53:31 -0700
> Ethan Furman wrote:
>
>> I just made a change to some error messages [1] (really, just one):
>>
>> old behavior:
>>
>>'%o' % 3.14
>>'float' object cannot be interpreted as an integer
>>
>> new behavior:
On Wed Mar 19 2014 at 2:46:48 PM, Antoine Pitrou
wrote:
>
> Hello,
>
> It is known to be cumbersome to write a proxy type that will correctly
> proxy all special methods (this has to be done manually on the type,
> since special methods are not looked up on the instance: a __getattr__
> method wo
On 19 March 2014 18:46, Antoine Pitrou wrote:
> In http://bugs.python.org/issue19359#msg213530 I proposed to introduce a
> "proxy
> protocol" (__proxy__ / tp_proxy) that would be used as a fallback by
> _PyObject_LookupSpecial to fetch the lookup target, i.e.:
>
> def _PyObject_LookupSpecial(obj,
On Wed, 19 Mar 2014 19:32:50 +
Brett Cannon wrote:
> >
> > In http://bugs.python.org/issue19359#msg213530 I proposed to introduce a
> > "proxy
> > protocol" (__proxy__ / tp_proxy) that would be used as a fallback by
> > _PyObject_LookupSpecial to fetch the lookup target, i.e.:
> >
> > def _PyO
On Wed, 19 Mar 2014 20:15:15 +
Paul Moore wrote:
> On 19 March 2014 18:46, Antoine Pitrou wrote:
> > In http://bugs.python.org/issue19359#msg213530 I proposed to introduce a
> > "proxy
> > protocol" (__proxy__ / tp_proxy) that would be used as a fallback by
> > _PyObject_LookupSpecial to fet
On 20 Mar 2014 02:37, "Stephen J. Turnbull" wrote:
>
> Kevin Modzelewski writes:
>
> > Sorry, I definitely didn't mean to imply that this kind of
> > optimization is valid on arbitrary subscript expressions; I thought
> > we had restricted ourselves to talking about builtin dicts.
>
> Ah, maybe
On 20 Mar 2014 07:38, "Nick Coghlan" wrote:
>
> Correct, but I think this discussion has established that "how many times
dict lookup calls __eq__ on the key" is one such thing. In CPython, it
already varies based on:
>
> - dict contents (due to the identity check and the distribution of
entries a
On 20 Mar 2014 06:24, "Antoine Pitrou" wrote:
>
> On Wed, 19 Mar 2014 19:32:50 +
> Brett Cannon wrote:
> > >
> > > In http://bugs.python.org/issue19359#msg213530 I proposed to
introduce a
> > > "proxy
> > > protocol" (__proxy__ / tp_proxy) that would be used as a fallback by
> > > _PyObject_L
On Thu, 20 Mar 2014 07:54:39 +1000
Nick Coghlan wrote:
>
> Graeme Dumpleton has also subsequently written a library to handle easier
> creation of correct proxy types: https://pypi.python.org/pypi/wrapt
(is "Graeme" another spelling for "Graham"?)
> It isn't as simple as changing one lookup fun
Here's the code in question:
class PsuedoFloat:
def __init__(self, value):
self.value = float(value)
def __int__(self):
return int(self.value)
pi = PsuedoFloat(3.1415)
self.assertRaisesRegex(TypeError, '%x format: a
On Wed, 19 Mar 2014 14:37:42 -0700
Ethan Furman wrote:
> Here's the code in question:
>
> class PsuedoFloat:
> def __init__(self, value):
> self.value = float(value)
> def __int__(self):
> return int(self.value)
>
> pi
On 03/19/2014 03:13 PM, Antoine Pitrou wrote:
On Wed, 19 Mar 2014 14:37:42 -0700
Ethan Furman wrote:
Here's the code in question:
class PsuedoFloat:
def __init__(self, value):
self.value = float(value)
def __int__(self):
On Wed, 19 Mar 2014 15:17:53 -0700
Ethan Furman wrote:
> On 03/19/2014 03:13 PM, Antoine Pitrou wrote:
> > On Wed, 19 Mar 2014 14:37:42 -0700
> > Ethan Furman wrote:
> >> Here's the code in question:
> >>
> >> class PsuedoFloat:
> >> def __init__(self, value):
> >>
On 03/19/2014 03:57 PM, Antoine Pitrou wrote:
On Wed, 19 Mar 2014 15:17:53 -0700
Ethan Furman wrote:
On 03/19/2014 03:13 PM, Antoine Pitrou wrote:
On Wed, 19 Mar 2014 14:37:42 -0700
Ethan Furman wrote:
Here's the code in question:
class PsuedoFloat:
def __init__(se
On Wed, Mar 19, 2014 at 4:13 PM, Ethan Furman wrote:
> On 03/19/2014 03:57 PM, Antoine Pitrou wrote:
>
>> On Wed, 19 Mar 2014 15:17:53 -0700
>> Ethan Furman wrote:
>>
>>> On 03/19/2014 03:13 PM, Antoine Pitrou wrote:
>>>
On Wed, 19 Mar 2014 14:37:42 -0700
Ethan Furman wrote:
On Wed, 19 Mar 2014 20:32:38 +0100, Georg Brandl wrote:
> Am 19.03.2014 19:55, schrieb Antoine Pitrou:
> > On Wed, 19 Mar 2014 10:53:31 -0700
> > Ethan Furman wrote:
> >
> >> I just made a change to some error messages [1] (really, just one):
> >>
> >> old behavior:
> >>
> >>'%o' % 3.14
>
On Wed, Mar 19, 2014 at 11:01:39PM +0100, Antoine Pitrou wrote:
> On Thu, 20 Mar 2014 07:54:39 +1000
> Nick Coghlan wrote:
> >
> > Graeme Dumpleton has also subsequently written a library to handle easier
> > creation of correct proxy types: https://pypi.python.org/pypi/wrapt
>
> (is "Graeme" an
On Wed, 19 Mar 2014 16:41:10 -0700, Thomas Wouters wrote:
> On Wed, Mar 19, 2014 at 4:13 PM, Ethan Furman wrote:
>
> > On 03/19/2014 03:57 PM, Antoine Pitrou wrote:
> >
> >> On Wed, 19 Mar 2014 15:17:53 -0700
> >> Ethan Furman wrote:
> >>
> >>> On 03/19/2014 03:13 PM, Antoine Pitrou wrote:
> >>
On 03/19/2014 04:41 PM, Thomas Wouters wrote:
What Antoine is trying to tell you is that the traceback you pasted shows this:
File "/home/ethan/source/python/__issue19995/Lib/test/test___unicode.py",
line 1156, in test_formatting
self.assertRaisesRegex(__TypeError, '%c'.__mod__, pi),
On 20 Mar 2014 10:34, "Steven D'Aprano" wrote:
>
> On Wed, Mar 19, 2014 at 11:01:39PM +0100, Antoine Pitrou wrote:
> > On Thu, 20 Mar 2014 07:54:39 +1000
> > Nick Coghlan wrote:
> > >
> > > Graeme Dumpleton has also subsequently written a library to handle
easier
> > > creation of correct proxy t
47 matches
Mail list logo