Re: [Python-Dev] Use an empty def as a lambda

2013-09-20 Thread Lennart Regebro
On Thu, Sep 19, 2013 at 10:54 PM, Ben Gift wrote: > I think the lambda keyword is difficult to understand for many people. It > would be more pythonic to use an empty def call instead. I agree, but that ship has sailed, at least until the time when Python 2 is dead. I don't want these kinds of sy

Re: [Python-Dev] Use an empty def as a lambda

2013-09-20 Thread Westley Martínez
'def' is no more ambiguous than 'lambda', and is in fact more ambiguous, for 'def' doesn't lend itself to anything other than the word define, whilst 'lambda' can only mean lambda function. Calling def explicit is silly. It only makes sense because def arbitrarily means a function in Python (I'm

Re: [Python-Dev] sys.intern should work on bytes

2013-09-20 Thread PJ Eby
On Fri, Sep 20, 2013 at 9:54 AM, Jesus Cea wrote: > Why str/bytes doesn't support weakrefs, beside memory use? The typical use case for weakrefs is to break reference cycles, but str and bytes can't *be* part of a reference cycle, so outside of interning-like use cases, there's no need for weakre

[Python-Dev] Summary of Python tracker Issues

2013-09-20 Thread Python tracker
ACTIVITY SUMMARY (2013-09-13 - 2013-09-20) Python tracker at http://bugs.python.org/ To view or respond to any of the issues listed below, click on the issue. Do NOT respond to this message. Issues counts and deltas: open4228 (+16) closed 26602 (+31) total 30830 (+47) Open issues wit

Re: [Python-Dev] sys.intern should work on bytes

2013-09-20 Thread Benjamin Peterson
2013/9/20 Jesus Cea : > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 20/09/13 15:44, Antoine Pitrou wrote: > >> Yes. The main difference is that sys.intern() will remove the >> interned strings when every external reference vanishes. It >> requires either weakref'ability (which both str a

Re: [Python-Dev] sys.intern should work on bytes

2013-09-20 Thread Jesus Cea
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 20/09/13 15:44, Antoine Pitrou wrote: > Yes. The main difference is that sys.intern() will remove the > interned strings when every external reference vanishes. It > requires either weakref'ability (which both str and bytes lack) or > special coope

[Python-Dev] dict.setdefault(object, object) instead of "sys.intern()" (was Re: sys.intern should work on bytes)

2013-09-20 Thread Jesus Cea
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 20/09/13 15:33, Benjamin Peterson wrote: > Well, the pickler should memoize bytes objects if you have lots of > the same one in a pickle... Only if they are the very same object. Not diferent bytes objects with the same value. Pickle doesn't do "a=

Re: [Python-Dev] sys.intern should work on bytes

2013-09-20 Thread Antoine Pitrou
Le Fri, 20 Sep 2013 15:33:05 +0200, Jesus Cea a écrit : > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 20/09/13 14:15, Antoine Pitrou wrote: > > From http://docs.python.org/3.3/library/sys.html#sys.intern > > > > """sys.intern(string) > > > > Enter string in the table of “interned” st

Re: [Python-Dev] sys.intern should work on bytes

2013-09-20 Thread Antoine Pitrou
Le Fri, 20 Sep 2013 15:36:45 +0200, Jesus Cea a écrit : > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 20/09/13 15:31, Antoine Pitrou wrote: > > sys.intern is an internal interpreter optimization and should be > > orthogonal to pickling. If pickle can't detect already-seen bytes > > o

Re: [Python-Dev] sys.intern should work on bytes

2013-09-20 Thread Jesus Cea
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 20/09/13 15:31, Antoine Pitrou wrote: > sys.intern is an internal interpreter optimization and should be > orthogonal to pickling. If pickle can't detect already-seen bytes > object, then you may file an improvement request on the bug > tracker.

Re: [Python-Dev] sys.intern should work on bytes

2013-09-20 Thread Benjamin Peterson
Well, the pickler should memoize bytes objects if you have lots of the same one in a pickle... 2013/9/20 Jesus Cea : > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 20/09/13 14:04, Victor Stinner wrote: >> What would you be the use case of interned bytes objets? > > Performance and memory

Re: [Python-Dev] sys.intern should work on bytes

2013-09-20 Thread Jesus Cea
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 20/09/13 14:15, Antoine Pitrou wrote: > From http://docs.python.org/3.3/library/sys.html#sys.intern > > """sys.intern(string) > > Enter string in the table of “interned” strings and return the > interned string [...]""" > > > In Python 3 contex

Re: [Python-Dev] sys.intern should work on bytes

2013-09-20 Thread Antoine Pitrou
Le Fri, 20 Sep 2013 15:14:37 +0200, Jesus Cea a écrit : > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 20/09/13 14:04, Victor Stinner wrote: > > What would you be the use case of interned bytes objets? > > Performance and memory. Pickle sizes (my particular issue now). sys.intern is a

Re: [Python-Dev] sys.intern should work on bytes

2013-09-20 Thread Jesus Cea
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 20/09/13 14:04, Victor Stinner wrote: > What would you be the use case of interned bytes objets? Performance and memory. Pickle sizes (my particular issue now). - -- Jesús Cea Avión _/_/ _/_/_/_/_/_/ j...@jcea

Re: [Python-Dev] sys.intern should work on bytes

2013-09-20 Thread Antoine Pitrou
Le Fri, 20 Sep 2013 13:19:24 +0200, Jesus Cea a écrit : > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > """ > sys.intern(b'12121212') > Traceback (most recent call last): > File "", line 1, in > TypeError: must be str, not bytes > """ > > I wonder why. From http://docs.python.org/3.3/l

Re: [Python-Dev] sys.intern should work on bytes

2013-09-20 Thread Victor Stinner
2013/9/20 Jesus Cea : > """ > sys.intern(b'12121212') > Traceback (most recent call last): > File "", line 1, in > TypeError: must be str, not bytes > """ > > I wonder why. Intern strings optimize dictionary lookup. In Python 3, most dictionaries use str keys (ex: __dict__ of classes). What wo

[Python-Dev] sys.intern should work on bytes

2013-09-20 Thread Jesus Cea
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 """ sys.intern(b'12121212') Traceback (most recent call last): File "", line 1, in TypeError: must be str, not bytes """ I wonder why. - -- Jesús Cea Avión _/_/ _/_/_/_/_/_/ j...@jcea.es - http://www.jcea.es/