Re: [Python-Dev] Unicode support of the curses module in Python 3.3

2012-09-01 Thread Steven D'Aprano
On 01/09/12 23:44, Victor Stinner wrote: Hi, I changed many functions of the curses module in Python 3.3 to improve its Unicode support: [...] Thank you. For example, if the Python curses module is not linked to libncursesw, get_wch() is not available and addch("é") raises an OverflowError

Re: [Python-Dev] Python 1.5 output file versions

2012-09-19 Thread Steven D'Aprano
On 19/09/12 18:51, Ido Yohanan wrote: Hi, I am working with PYTHON 1.5 and want to control versions of every pyo file. Python 1.5? Are you serious? Python 1.5 is now at least 8 versions obsolete, and hasn't been updated since approximately 1995. Is there any way I can assign a file versio

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Steven D'Aprano
On 20/09/12 22:59, Mark Dickinson wrote: On Thu, Sep 20, 2012 at 1:21 PM, Nick Coghlan wrote: +1 for using the unqualified "argument" in these error messages to mean "positional or keyword argument" (inspect.Parameter spells it out as POSITIONAL_OR_KEYWORD, but the full phrase is far too verbos

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Steven D'Aprano
On 21/09/12 00:49, Antoine Pitrou wrote: On Thu, 20 Sep 2012 10:12:04 -0400 Benjamin Peterson wrote: 2012/9/20 Mark Dickinson: Thoughts? I tried to define the error messages in terms of the callee's signature. I call the formals that are not variadic, keyword variadic, or keyword-only, posit

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Steven D'Aprano
On 21/09/12 01:53, Oscar Benjamin wrote: Mark Dickinson wrote: def f(x): pass ... f() Traceback (most recent call last): File "", line 1, in TypeError: f() missing 1 required positional argument: 'x' I would say that the only problem with this terminology is that it would be good to thin

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Steven D'Aprano
On 21/09/12 05:45, Ethan Furman wrote: I don't expect error messages to give a complete catalog of every problem with a specific function call. If f() reports that required argument 'a' is missing, that does not imply that no other required arguments are also missing. I think it is perfectly acc

Re: [Python-Dev] "Decimal(2) != float(2)"???

2012-09-29 Thread Steven D'Aprano
On 30/09/12 10:43, Jan Kaliszewski wrote: Hello, In http://docs.python.org/release/3.2.3/reference/expressions.html#in we read: "[...] This can create the illusion of non-transitivity between supported cross-type comparisons and unsupported comparisons. For example, Decimal(2) == 2 and 2 == floa

Re: [Python-Dev] Benchmarking Python 3.3 against Python 2.7 (wide build)

2012-09-30 Thread Steven D'Aprano
On Sun, Sep 30, 2012 at 07:12:47PM -0400, Brett Cannon wrote: > > python3 perf.py -T --basedir ../benchmarks -f -b py3k > ../cpython/builds/2.7-wide/bin/python ../cpython/builds/3.3/bin/python3.3 > ### call_method ### > Min: 0.491433 -> 0.414841: 1.18x faster > Avg: 0.493640 -> 0.416564: 1.19x fa

Re: [Python-Dev] Should vars() return modifiable dict?

2012-10-03 Thread Steven D'Aprano
On 03/10/12 18:54, Serhiy Storchaka wrote: For locals vars() returns... hmm, partially modifiable dict: >> def f(): ... x = 42 ... print(vars()) ... vars()['x'] = 43 ... vars()['y'] = 44 ... print(x, vars()) ... >> f() {'x': 42} 42 {'y': 44, 'x': 42} Should behavior of vars() be corrected

Re: [Python-Dev] Should vars() return modifiable dict?

2012-10-05 Thread Steven D'Aprano
On 05/10/12 22:58, Nick Coghlan wrote about locals(): As for *why* changes don't get written back, it's because the compiler is allowed to assume it knows about every variable name that exists in the local scope (by design), and that doesn't fit with writable locals() for functions. And to be

[Python-Dev] Issue 8492 [was Re: [Python-dev] History stepping in interactive session?]

2012-10-07 Thread Steven D'Aprano
Over on python-ideas, a question about readline was raised and, I think, resolved. But while investigating the question, it became obvious to me that the ability to inspect the current readline bindings from Python was both useful and important. I wrote: I don't believe that there is any direct

Re: [Python-Dev] Why not using the hash when comparing strings?

2012-10-18 Thread Steven D'Aprano
On 19/10/12 12:03, Victor Stinner wrote: Hi, I would like to know if there a reason for not using the hash of (bytes or unicode) strings when comparing two objects and the hash of the two objects was already been computed. Using the hash would speed up comparaison of long strings when the two st

Re: [Python-Dev] return type of __complex__

2012-10-20 Thread Steven D'Aprano
On 20/10/12 01:13, Nick Coghlan wrote: On Fri, Oct 19, 2012 at 11:08 PM, Antonio Cuni wrote: Is that the real intended behavior? Given the way complex numbers interact with floats generally, returning a complex number with no imaginary component as a floating point value seems legitimate S

Re: [Python-Dev] return type of __complex__

2012-10-20 Thread Steven D'Aprano
On 21/10/12 06:28, Tres Seaver wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 10/19/2012 07:35 PM, Greg Ewing wrote: Antonio Cuni wrote: Traceback (most recent call last): File "", line 1, in TypeError: __complex__ should return a complex object i.e., the complex constructor does n

Re: [Python-Dev] return type of __complex__

2012-10-21 Thread Steven D'Aprano
On 21/10/12 19:47, Serhiy Storchaka wrote: On 21.10.12 09:05, Greg Ewing wrote: The equivalent solution here would be to add a new operator for complex exponentiation that coerces its operands to complex, and restrict the existing one to floats only. In case of division a new operator (//) res

Re: [Python-Dev] return type of __complex__

2012-10-21 Thread Steven D'Aprano
On 21/10/12 13:57, Nick Coghlan wrote: On Sun, Oct 21, 2012 at 11:53 AM, Steven D'Aprano wrote: Python 2.x legitimately distinguished between floats and complex, e.g.: py> (-100.0)**0.5 Traceback (most recent call last): File "", line 1, in ValueError: negative numbe

Re: [Python-Dev] return type of __complex__

2012-10-21 Thread Steven D'Aprano
On 21/10/12 21:11, Antoine Pitrou wrote: On Sun, 21 Oct 2012 13:38:48 +1100 Chris Angelico wrote: On Sun, Oct 21, 2012 at 12:53 PM, Steven D'Aprano wrote: Python 2.x legitimately distinguished between floats and complex, e.g.: py> (-100.0)**0.5 Traceback (most recent call last):

Re: [Python-Dev] return type of __complex__

2012-10-21 Thread Steven D'Aprano
On Mon, Oct 22, 2012 at 02:25:45PM +1100, Chris Angelico wrote: > There really aren't that many situations where a program will be > completely oblivious of complex/imaginary numbers and be able to > encounter them... are there? Fortunately the math module does not promote float to complex: py>

Re: [Python-Dev] Fwd: Python 3.3 can't sort memoryviews as they're unorderable

2012-10-25 Thread Steven D'Aprano
On 26/10/12 02:57, Mark Lawrence complained that he can't subclass memoryviews: I'm guessing that I've missed something that's blatantly obvious to everybody except myself. I can't find a rationale anywhere as to why I can't subclass memoryviews for my code, so I can't work around what I perceiv

Re: [Python-Dev] Improve error message "UnboundLocalError: local variable referenced before assignment"

2012-10-31 Thread Steven D'Aprano
On 01/11/12 06:57, anatoly techtonik wrote: [...] UnboundLocalError: local variable 'FONT_NAMES' referenced before assignment As you may see there is inconsistency between handling of line 6 - "if len(DEBUG):" and line 8 - "if len(FONT_NAMES):". This is very magical and hard to troubleshoot.

Re: [Python-Dev] chained assignment weirdity

2012-11-07 Thread Steven D'Aprano
On 08/11/12 08:39, Ned Batchelder wrote: Just to be clear: the reference guide says that the behavior *SHOULD BE* (but is not yet) this: Python 3.3.0 >> {print("a"):print("b")} a b {None: None} That was the behaviour of Python 2.4: py> def pr(x): ... print x ... py> {pr(1): pr(2), pr

Re: [Python-Dev] performance of {} versus dict()

2012-11-14 Thread Steven D'Aprano
On 14/11/12 21:00, Chris Withers wrote: On 14/11/2012 09:58, Merlijn van Deen wrote: On 14 November 2012 10:12, Chris Withers wrote: ...which made me a little sad Why did it make you sad? dict() takes 0.2µs, {} takes 0.04µs. In other words: you can run dict() _five million_ times per second,

Re: [Python-Dev] performance of {} versus dict()

2012-11-14 Thread Steven D'Aprano
On 15/11/12 05:54, Mark Adam wrote: Merging of two dicts is done with dict.update. How do you do it on initialization? This doesn't make sense. Frequently. my_prefs = dict(default_prefs, setting=True, another_setting=False) Notice that I'm not merging one dict into another, but merging t

Re: [Python-Dev] slightly misleading Popen.poll() docs

2012-12-05 Thread Steven D'Aprano
On 06/12/12 03:08, Chris Withers wrote: I'd like to change the docs for poll() to say: """ Check if child process has terminated. If it has, the returncode attribute will be set and that value will be returned. If it has not, None will be returned and the returncode attribute will remain None.

[Python-Dev] Conflicts [was Re: Keyword meanings [was: Accept just PEP-0426]]

2012-12-08 Thread Steven D'Aprano
On 09/12/12 08:14, MRAB wrote: If package A says that it conflicts with package B, it may or may not be symmetrical, because it's possible that package B has been updated since the author of package A discovered the conflict, so it's important that the user is told which package is complaining a

Re: [Python-Dev] Conflicts [was Re: Keyword meanings [was: Accept just PEP-0426]]

2012-12-08 Thread Steven D'Aprano
On 09/12/12 12:32, Chris Angelico wrote: On Sun, Dec 9, 2012 at 12:15 PM, Steven D'Aprano wrote: Assuming that two software packages Spam and Ham install into directories Spam and Ham, how can merely having them installed side-by-side lead to a conflict? I can see how running or impo

Re: [Python-Dev] More compact dictionaries with faster iteration

2012-12-10 Thread Steven D'Aprano
On 10/12/12 20:40, Armin Rigo wrote: As a side note, your suggestion also enables order-preserving dictionaries: iter() would automatically yield items in the order they were inserted, as long as there was no deletion. People will immediately start relying on this "feature"... and be confused

Re: [Python-Dev] Draft PEP for time zone support.

2012-12-28 Thread Steven D'Aprano
On 29/12/12 05:02, Lennart Regebro wrote: On Thu, Dec 20, 2012 at 5:43 PM, Barry Warsaw wrote: That would be `class UnknownTimeZoneError(ValueError, TimeZoneError)`. As of today, in Pytz, UnknownTimeZoneError in fact subclasses KeyError. Any opinions against that? The PEP says: * New

Re: [Python-Dev] Draft PEP for time zone support.

2012-12-30 Thread Steven D'Aprano
On 29/12/12 15:40, Lennart Regebro wrote: On Sat, Dec 29, 2012 at 2:23 AM, Steven D'Apranowrote: The PEP says: * New function :``timezone(name=None, db_path=None)`` This function takes a name string that must be a string specifying a valid zoneinfo timezone, ie "US/Eastern", "Europe/Wa

Re: [Python-Dev] PEP 431 Time zone support improvements - Update

2012-12-30 Thread Steven D'Aprano
On 30/12/12 07:16, Lennart Regebro wrote: If no database is found an ``UnknownTimeZoneError`` or subclass thereof will be raised with a message explaining that no zoneinfo database can be found, but that you can install one with the ``tzdata-update`` package. Why should we car

Re: [Python-Dev] PEP 431 Updates

2013-01-28 Thread Steven D'Aprano
On 28/01/13 23:52, Antoine Pitrou wrote: Le Mon, 28 Jan 2013 22:31:29 +1000, Nick Coghlan a écrit : 6. Under "New collections" Why both lists and sets? Because pytz did it. But yes, you are right, an ordered set is a better solution. Baseing it on OrderedDict seems like a hack, though. I c

Re: [Python-Dev] Submitting PEP 422 (Simple class initialization hook) for pronouncement

2013-02-11 Thread Steven D'Aprano
On 12/02/13 10:56, Jan Kaliszewski wrote: Wouldn't __initclass__ be readable enough? IMHO it could spare users trouble with remembering special case. +1 I approve of the colour of this bikeshed. __init_class__ has too many underscores. -- Steven _

Re: [Python-Dev] what is a dict_keys and where can I import it from?

2013-02-12 Thread Steven D'Aprano
On 12/02/13 18:05, Chris Withers wrote: Hi all, So, dicts in Python 3 return "something different" from their keys and values methods: >> dict(x=1, y=2).keys() dict_keys(['y', 'x']) >> type(dict(x=1, y=2).keys()) I have vague memories of these things being referred to as views or some su

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-13 Thread Steven D'Aprano
On 13/02/13 19:52, Larry Hastings wrote: I've always hated the "".join(array) idiom for "fast" string concatenation --it's ugly and it flies in the face of TOOWTDI. I think everyone should use "x = a + b + c + d" for string concatenation, and we should just make that fast. "".join(array) is

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-13 Thread Steven D'Aprano
On 13/02/13 20:09, Chris Withers wrote: On 12/02/2013 21:03, Maciej Fijalkowski wrote: We recently encountered a performance issue in stdlib for pypy. It turned out that someone commited a performance "fix" that uses += for strings instead of "".join() that was there before. That's... interest

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-13 Thread Steven D'Aprano
On 13/02/13 22:46, Xavier Morel wrote: On 2013-02-13, at 12:37 , Steven D'Aprano wrote: # even less obvious than sum map(operator.add, array) That one does not work, it'll try to call the binary `add` with each item of the array when the map iterator is reified, er

Re: [Python-Dev] efficient string concatenation (yep, from 2004)

2013-02-13 Thread Steven D'Aprano
On 13/02/13 10:53, Christian Tismer wrote: Hi friends, _efficient string concatenation_ has been a topic in 2004. Armin Rigo proposed a patch with the name of the subject, more precisely: /[Patches] [ python-Patches-980695 ] efficient string concatenation// //on sourceforge.net, on 2004-06-28./

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-13 Thread Steven D'Aprano
On 14/02/13 01:18, Chris Withers wrote: On 13/02/2013 11:53, Steven D'Aprano wrote: I fixed a performance bug in httplib some years ago by doing the exact opposite; += -> ''.join(). In that case, it changed downloading a file from 20 minutes to 3 seconds. That was likely o

Re: [Python-Dev] [pypy-dev] efficient string concatenation (yep, from 2004)

2013-02-13 Thread Steven D'Aprano
On 14/02/13 01:44, Nick Coghlan wrote: Deliberately *relying* on the += hack to avoid quadratic runtime is just plain wrong, and our documentation already says so. +1 I'm not sure that there's any evidence that people in general are *relying* on the += hack. More likely they write the first

<    11   12   13   14   15   16