[Python-Dev] sys.intern should work on bytes
-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 _/_/ _/_/_/_/_/_/ [email protected] - http://www.jcea.es/ _/_/_/_/ _/_/_/_/ _/_/ Twitter: @jcea_/_/_/_/ _/_/_/_/_/ jabber / xmpp:[email protected] _/_/ _/_/_/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/_/_/ _/_/_/_/ _/_/ "My name is Dump, Core Dump" _/_/_/_/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQCVAwUBUjwvPJlgi5GaxT1NAQIINQP/ZmEyPBSapa52yZRhQf8QSVSBm5tXpWrC k9MbcvsK/5K6ArRogkulk1GSu1EJPPvuHMAXX8EenNFBXPvDRm0mOxrHkcYw5IKx Ml2ORENm+EEM/ziUJMRtY4aqD5Jp6pXSSl9UmP5OQMDJfuabSrVqs7X2409OOhUj BXeg9HvURxo= =78M+ -END PGP SIGNATURE- ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] sys.intern should work on bytes
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 would you be the use case of interned bytes objets? Victor ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] sys.intern should work on bytes
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/library/sys.html#sys.intern """sys.intern(string) Enter string in the table of “interned” strings and return the interned string [...]""" In Python 3 context, "string" means "str". Regards Antoine. ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] sys.intern should work on bytes
-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 _/_/ _/_/_/_/_/_/ [email protected] - http://www.jcea.es/ _/_/_/_/ _/_/_/_/ _/_/ Twitter: @jcea_/_/_/_/ _/_/_/_/_/ jabber / xmpp:[email protected] _/_/ _/_/_/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/_/_/ _/_/_/_/ _/_/ "My name is Dump, Core Dump" _/_/_/_/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQCVAwUBUjxKPZlgi5GaxT1NAQJ6FwQAim2H+OGpRD75KplahNhnKIfm9AUqVnHg CaLakWhADdHBYlit+DxRQsxtv5C7gyhhqMryydyvx97z33VaI2p1RGOOcK/lWdNw ETcetqJo8UswS2PSthJ0e5snOUsIeVJRomhJ48n8sJfIadCxAk6ozdMR75pHP5Y3 lJoUuUgdcJU= =vbuK -END PGP SIGNATURE- ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] sys.intern should work on bytes
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 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. Regards Antoine. ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] sys.intern should work on bytes
-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 context, "string" means "str". I read that, Antoine. In fact I read the manual, I thought it was a mistake carried over from 2.x documentation, I tried it just in case before reporting the "documentation mistake", and I was surprised it was actually true :-). I know that intern is used for performance reasons internally to the interpreter. But I am thinking about memory usage optimizations. For instance, I have a pickle that is 14MB in size, when "interning" the strings on it (there are a lot of redundancy), the new size is only 3MB and it loads faster. I can do it because most data in the pickle are strings, I could NOT do it if I used bytes. I could do a manual "intern" for hashable objects by hand using an "object:object" dictionary (that would work for integers too), but I wonder if extending builtin "sys.intern" would be something to consider. Anyway, this pattern is easy enough: Instead of object = sys.intern(object) I could do interned = dict() ... object = interned.setdefault(object, object) - -- Jesús Cea Avión _/_/ _/_/_/_/_/_/ [email protected] - http://www.jcea.es/ _/_/_/_/ _/_/_/_/ _/_/ Twitter: @jcea_/_/_/_/ _/_/_/_/_/ jabber / xmpp:[email protected] _/_/ _/_/_/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/_/_/ _/_/_/_/ _/_/ "My name is Dump, Core Dump" _/_/_/_/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQCVAwUBUjxOkZlgi5GaxT1NAQIOVgQAhN36yRAAQP1YWbDsXGSamgZnhEULTloB penRZYTYz/Ir/VM9l27GoXS7ThGrucAkkYZoJqXnUr2vyP0hq6rsfp+N5lzl61Nf mDJBCtAczzKNdYqQSgMQ+Ugk43KnbEFFX7SB9Y5IkYroWCeWq7+5y6KX3ZKBspXG lmXotLgpvW0= =/RNw -END PGP SIGNATURE- ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] sys.intern should work on bytes
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. Pickle sizes (my particular issue now). > > - -- > Jesús Cea Avión _/_/ _/_/_/_/_/_/ > [email protected] - http://www.jcea.es/ _/_/_/_/ _/_/_/_/ _/_/ > Twitter: @jcea_/_/_/_/ _/_/_/_/_/ > jabber / xmpp:[email protected] _/_/ _/_/_/_/ _/_/ _/_/ > "Things are not so easy" _/_/ _/_/_/_/ _/_/_/_/ _/_/ > "My name is Dump, Core Dump" _/_/_/_/_/_/ _/_/ _/_/ > "El amor es poner tu felicidad en la felicidad de otro" - Leibniz > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.10 (GNU/Linux) > Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ > > iQCVAwUBUjxKPZlgi5GaxT1NAQJ6FwQAim2H+OGpRD75KplahNhnKIfm9AUqVnHg > CaLakWhADdHBYlit+DxRQsxtv5C7gyhhqMryydyvx97z33VaI2p1RGOOcK/lWdNw > ETcetqJo8UswS2PSthJ0e5snOUsIeVJRomhJ48n8sJfIadCxAk6ozdMR75pHP5Y3 > lJoUuUgdcJU= > =vbuK > -END PGP SIGNATURE- > ___ > Python-Dev mailing list > [email protected] > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > https://mail.python.org/mailman/options/python-dev/benjamin%40python.org -- Regards, Benjamin ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] sys.intern should work on bytes
-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. Understood. Thanks for the clarification. Pickle manage correctly "same object" references, but not "different objects but equivalent". That is the issue. But for most uses this is not a problem, and implementing this redundance removal looks like a performance cost that few users would benefice from, but everybody pays. Pickle is already slow enough now :). - -- Jesús Cea Avión _/_/ _/_/_/_/_/_/ [email protected] - http://www.jcea.es/ _/_/_/_/ _/_/_/_/ _/_/ Twitter: @jcea_/_/_/_/ _/_/_/_/_/ jabber / xmpp:[email protected] _/_/ _/_/_/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/_/_/ _/_/_/_/ _/_/ "My name is Dump, Core Dump" _/_/_/_/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQCVAwUBUjxPbZlgi5GaxT1NAQIyYQQAplpwDnz2/0bNTF7KN7V0PQnXZQknEnvL 0VACm298Y386hs8bJQFlRlTOzfhguulaaEwdqLaBPkXMKA7LBaVRHM1v5o+Xb40X 7DwSKglkbt6HgX7/nDMX4qk9Kxb2ZEVz+XOozPta2NRoZmaz8y7Xyqc/+4+UTzHH XsNJ2H5yVEo= =GPtw -END PGP SIGNATURE- ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] sys.intern should work on bytes
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 > > object, then you may file an improvement request on the bug > > tracker. > > Understood. Thanks for the clarification. > > Pickle manage correctly "same object" references, but not "different > objects but equivalent". That is the issue. Ah, well, in that case the issue is not in pickle, it's in your code. pickle doesn't try to guess if "equal" is really functionally equivalent to "identical". Regards Antoine. ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] sys.intern should work on bytes
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” strings and return the > > interned string [...]""" > > > > > > In Python 3 context, "string" means "str". > > I read that, Antoine. In fact I read the manual, I thought it was a > mistake carried over from 2.x documentation, I tried it just in case > before reporting the "documentation mistake", and I was surprised it > was actually true :-). > > I know that intern is used for performance reasons internally to the > interpreter. But I am thinking about memory usage optimizations. For > instance, I have a pickle that is 14MB in size, when "interning" the > strings on it (there are a lot of redundancy), the new size is only > 3MB and it loads faster. I can do it because most data in the pickle > are strings, I could NOT do it if I used bytes. > > I could do a manual "intern" for hashable objects by hand using an > "object:object" dictionary (that would work for integers too), but I > wonder if extending builtin "sys.intern" would be something to > consider. > > Anyway, this pattern is easy enough: > > Instead of > > object = sys.intern(object) > > I could do > > interned = dict() > ... > object = interned.setdefault(object, object) 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 cooperation from the object destructor (which is why sys.intern() is restricted to str instead of working with arbitrary objects). Regards Antoine. ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] dict.setdefault(object, object) instead of "sys.intern()" (was Re: sys.intern should work on bytes)
-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==b" but "id(a)==id(b)". Yes, I know that "a==b" would break mutable objects. It is just an example. I don't want to pursue that path. Performance of pickle is already appallingly slow. In my project, I will do the redundancy removal on my own way, as explained in ither message on this thread. Example: * Original pickle: 14416284 bytes * Pickle with "interned" strings: 3004880 bytes (quite an improvement, but this is particular to my case, I have a lot of string duplications here. The pickle also loads a bit faster) * Pickle including an extra dictionary of "interned" strings, created using the "interned.setdefault(object,object)" pattern: 5126587 bytes. Sniff. Could I do this more compactly?. - -- Jesús Cea Avión _/_/ _/_/_/_/_/_/ [email protected] - http://www.jcea.es/ _/_/_/_/ _/_/_/_/ _/_/ Twitter: @jcea_/_/_/_/ _/_/_/_/_/ jabber / xmpp:[email protected] _/_/ _/_/_/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/_/_/ _/_/_/_/ _/_/ "My name is Dump, Core Dump" _/_/_/_/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQCVAwUBUjxRwZlgi5GaxT1NAQKW8wP/dhVa/v3RZbOKvOtogpHGs5nZyjhtChwn lFK1Lr1wl/+6IgCjgu9axkrRM0LLRaBN91HW+e9AkAM9XSFBQp6qAAqjJpI/jLDp xRLW9fMRHpD21m1tG9zxziz4ACCLNNDnlsyY9l7oHHbMzaAX6Gbigyml3hEbj0uK G5hk4VhyKEY= =m/3T -END PGP SIGNATURE- ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] sys.intern should work on bytes
-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 cooperation from the object destructor (which is why > sys.intern() is restricted to str instead of working with arbitrary > objects). Great comment. Thanks. Why str/bytes doesn't support weakrefs, beside memory use? - -- Jesús Cea Avión _/_/ _/_/_/_/_/_/ [email protected] - http://www.jcea.es/ _/_/_/_/ _/_/_/_/ _/_/ Twitter: @jcea_/_/_/_/ _/_/_/_/_/ jabber / xmpp:[email protected] _/_/ _/_/_/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/_/_/ _/_/_/_/ _/_/ "My name is Dump, Core Dump" _/_/_/_/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQCVAwUBUjxTqJlgi5GaxT1NAQIbvwP/fs7e5MJwF0pCa0NObTx0xN8CFQIX9/jt VkQ1Q7lPLSuRlZMC2B+0xfp9QoAsD6N3xqSXwG+T9uf7w6nZ9y3keI06kAdSn/Cz D8EyxoeuNk2aGq0VIzMO260mgs9Gr+3DtWAROcWCMG+8sr5uekJ/LAhI04/xMkqZ zr7aOy1xDgk= =hzGP -END PGP SIGNATURE- ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] sys.intern should work on bytes
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 and bytes lack) or >> special cooperation from the object destructor (which is why >> sys.intern() is restricted to str instead of working with arbitrary >> objects). > > Great comment. Thanks. > > Why str/bytes doesn't support weakrefs, beside memory use? Is increased memory use for every str/bytes object not a good enough reason? -- Regards, Benjamin ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] Summary of Python tracker Issues
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 with patches: 1949 Issues opened (37) == #12085: subprocess.Popen.__del__ raises AttributeError if __init__ was http://bugs.python.org/issue12085 reopened by serhiy.storchaka #14927: add "Do not supply 'int' argument" to random.shuffle docstring http://bugs.python.org/issue14927 reopened by orsenthil #19011: Enum should have a __getattr__ that makes all the instances av http://bugs.python.org/issue19011 opened by lambacck #19012: urllib2: bad proxy configuration throws "getaddrinfo" error http://bugs.python.org/issue19012 opened by SjoerdOptLand #19014: Allow memoryview.cast() for empty views http://bugs.python.org/issue19014 opened by serhiy.storchaka #19016: autospecced namedtuples should be truthy by default http://bugs.python.org/issue19016 opened by skrisman #19017: selectors: towards uniform EBADF handling http://bugs.python.org/issue19017 opened by neologix #19019: Investigate using Apple clang for building OS X installers http://bugs.python.org/issue19019 opened by ned.deily #19020: Regression: Windows-tkinter-idle, unicode, and 0xxx filename http://bugs.python.org/issue19020 opened by terry.reedy #19021: AttributeError in Popen.__del__ http://bugs.python.org/issue19021 opened by serhiy.storchaka #19022: Improve handling of type.__abstractmethods__ descriptor http://bugs.python.org/issue19022 opened by ncoghlan #19023: ctypes docs: Unimplemented and undocumented features http://bugs.python.org/issue19023 opened by syeberman #19024: Document asterisk (*), splat or star operator http://bugs.python.org/issue19024 opened by techtonik #19025: Deleting attribute of Enum gives misleading error message http://bugs.python.org/issue19025 opened by vajrasky #19027: undefined symbol: _PyParser_Grammar http://bugs.python.org/issue19027 opened by arigo #19028: tkinter.tkapp.merge() fails on non-strings http://bugs.python.org/issue19028 opened by serhiy.storchaka #19030: inspect.getmembers and inspect.classify_class_attrs mishandle http://bugs.python.org/issue19030 opened by ethan.furman #19031: Make help() enum aware http://bugs.python.org/issue19031 opened by ethan.furman #19034: More useful repr for Tcl_Obj http://bugs.python.org/issue19034 opened by serhiy.storchaka #19035: tokenize.generate_tokens treat '\f' symbol as the end of file http://bugs.python.org/issue19035 opened by Alexey.Umnov #19036: setlocale fails due to locale.h being wrapped up in LANGINFO c http://bugs.python.org/issue19036 opened by alanh #19040: Problems with overriding Enum.__new__ http://bugs.python.org/issue19040 opened by Drekin #19042: Idle: add option to autosave 'Untitled' edit window http://bugs.python.org/issue19042 opened by terry.reedy #19043: Remove detailed listing of all versions from LICENSE, Doc/lice http://bugs.python.org/issue19043 opened by georg.brandl #19044: getaddrinfo raises near-useless exception http://bugs.python.org/issue19044 opened by Nikratio #19045: Make on Solaris 11 x64 with OracleStudio12.3 failed http://bugs.python.org/issue19045 opened by podlipnik #19046: SystemError: ..\Objects\weakrefobject.c:903: bad argument to i http://bugs.python.org/issue19046 opened by mherrmann.at #19047: Assorted weakref docs improvements http://bugs.python.org/issue19047 opened by ncoghlan #19048: itertools.tee doesn't have a __sizeof__ method http://bugs.python.org/issue19048 opened by pitrou #19049: itertools.tee uses int for indices http://bugs.python.org/issue19049 opened by pitrou #19050: crash while writing to a closed file descriptor http://bugs.python.org/issue19050 opened by damiro #19051: Unify buffered readers http://bugs.python.org/issue19051 opened by serhiy.storchaka #19053: read1() from zipfile returns empty data http://bugs.python.org/issue19053 opened by serhiy.storchaka #19054: Descriptors howto http://bugs.python.org/issue19054 opened by marco.buttu #19055: Regular expressions: * does not match as many repetitions as p http://bugs.python.org/issue19055 opened by Jason.Stumpf #19056: Windows 7, script exec not working without explicit cal of pyt http://bugs.python.org/issue19056 opened by tsunwell #19057: Sometimes urllib2 raises URLError when trying POST with httpS http://bugs.python.org/issue19057 opened by mrDoctorWho0.. Most recent 15 issues with no replies (15) == #19056: Windows 7, script exec not working without explicit cal of pyt http://bugs.python.org/issue19056 #19054: Descriptors howto http://bugs.python.org/issue19054 #19040: Problems with overriding Enum.__new__ http://bugs.python.org/issue19040 #19034: More useful repr for Tcl_Obj http://bugs.python.org/issue19
Re: [Python-Dev] sys.intern should work on bytes
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 weakref support there. ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Use an empty def as a lambda
'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 proposing def become func or proc in Python 4000). To call lambda too 'computer sciencey' is equally ridiculous, for pro- gramming is a key spawn of computer science. A programmer needs to have some knowledge of computer science to program, just like a physicist needs knowledge of calculus to understand mechanics. > -Original Message- > From: Python-Dev [mailto:[email protected]] On > Behalf Of Ben Gift > Sent: Thursday, September 19, 2013 1:54 PM > To: [email protected] > Subject: [Python-Dev] Use an empty def as a lambda > > I think the lambda keyword is difficult to understand for many people. It > would be more pythonic to use an empty def call instead. > > > For instance this: > > > words.sort(key = lambda x: x[2]) > > > could look like this: > > words.sort(key = def (x): x[2]) > > > It's obvious and explicit that we're creating an unnamed, anonymous function > this way. ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Use an empty def as a lambda
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 syntax changes for a *long* time now, personally. //Lennart ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
