[Python-Dev] r62342 - python/branches/py3k/Objects/bytesobject.c
Neal Norwitz
nnorwitz at gmail.com
Tue Apr 22 06:46:10 CEST 2008
On Tue, Apr 15, 2008 at 2:21 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Neal Norwitz wrote:
> > Iteration with the dict methods (e.g., keys -> iterkeys()),
> > map/zip/filter returning iterator rather than list.
>
> That's only an optimisation, it's not functionally required. A list behaves
> like an iterator in most use cases, so it's rather unlikely that Py3 code will
> break in the backport because of this (and it's very unlikely that static
> analysis can catch the cases where it breaks). There should be a rule to
> optimise "list(map(...))" into "map(...)" and "list(x.keys())" into plain
> "x.keys()" etc., but I don't think there is much more to do here.
It's not just an optimization if a copy won't fit in memory. I'd like
the solution to be closer to 100% than 95%.
> > int -> (int, long)
>
> Is there any case where this might be required? I don't see any reason why
> back-converted Py3 code should break here. What would "long()" be needed for
> in working Py3 code that "int()" doesn't provide in Py2?
>
> Although you might have been referring to "isinstance(x, int)" in Py3?
Yes, sorry, I wasn't explicit. isinstance is specifically what I was
referring to (or other type checks such as type(x) in (int, long)).
> > str -> basestring or (str, unicode)
>
> This is an issue, although I think that Py3 is explicit enough here to make
> this easy to handle by static renaming (and maybe optimising "isinstance(s,
> (str, bytes))" into "..., basestring))").
>
>
>
> > __bool__ -> __nonzero__
> > exec/execfile
> > input -> rawinput
>
> Also valid issues that can be handled through renaming and static syntactic
> adjustments.
>
>
>
> > Most things that have a fixer in 2to3 would also require one in 3to2.
>
> I think the more explicit syntax in Py3 will actually make it easier to
> back-convert the code statically from 3to2 than to migrate it from 2to3.
Sure, that's the idea.
I haven't seen any action on 3to2 (although I'm very behind on email).
Stefan, could you try to implement some of these and report back how
it works?
n
More information about the Python-Dev
mailing list