[Python-Dev] GitHub mirror (Was: Bitbucket mirror?)
On Fri, Jun 29, 2012 at 6:58 AM, Eli Bendersky wrote: > > The devguide (http://docs.python.org/devguide/committing.html) says: > > Bitbucket also maintain an up to date clone of the main cpython repository > that can be used as the basis for a new clone or patch queue. > > [the link goes to https://bitbucket.org/mirror/cpython/overview] This one is better than Atlassian's (looks nice, shorter URL) and worked long before Atlassian promotion as "makers of Bitbucket", which is dead wrong BTW, because everybody knows they bought BB. I don't remember if I commented on the Python Insider or if it was censored. Whatever.. it hurts Atlassian, not me. On the subject. Is there a mirror of CPython on GitHub? I abandoned my efforts to create online editor for docs, which should have been both web fronted independent, maintainable and clean. It appeared much easier to just use GitHub - so far it is the only one from open source code hosting services that directly commits online changes to repository (and allows anonymous to do this). I've made more than a dozen proposal for fixing docs, because as a matter of fact - filling a bug AND explaining why docs are wrong, why they need to be fixed, what should be added - all of this is a way *much easier* (and less time consuming!) than just fixing them. Unfortunately. ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] GitHub mirror
anatoly techtonik writes: > On the subject. Is there a mirror of CPython on GitHub? https://github.com/schmir/python -- Cheers Ralf ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [Python-ideas] itertools.chunks(iterable, size, fill=None)
On Fri, Jun 29, 2012 at 11:32 PM, Georg Brandl wrote:
> On 26.06.2012 10:03, anatoly techtonik wrote:
>>
>> Now that Python 3 is all about iterators (which is a user killer
>> feature for Python according to StackOverflow -
>> http://stackoverflow.com/questions/tagged/python) would it be nice to
>> introduce more first class functions to work with them? One function
>> to be exact to split string into chunks.
>>
>> itertools.chunks(iterable, size, fill=None)
>>
>> Which is the 33th most voted Python question on SO -
>>
>> http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python/312464
>>
>> P.S. CC'ing to python-dev@ to notify about the thread in python-ideas.
>>
>
> Anatoly, so far there were no negative votes -- would you care to go
> another step and propose a patch?
Was about to say "no problem", but in fact - there is. Sorry from
whining from my side and thanks for nudging. The only thought that a
simple task of copy/pasting relevant code from
http://docs.python.org/library/itertools.html?highlight=itertools#recipes
will require a few hours waiting of download (still not everybody has
a high-speed internet) makes me switch to other less time consuming
tasks before getting around to it. These tasks become more important
in a few hours, and basically I've passed through this many times
before. It then becomes quite hard to switch back.
I absolutely don't mind someone else being credited for the idea,
because ideas usually worthless without implementation. It will be
interesting to design how the process could work in a separate thread.
For now the best thing I can do (I don't risk even to mention anything
with 3.3) is to copy/paste code from the docs here:
from itertools import izip_longest
def chunks(iterable, size, fill=None):
"""Split an iterable into blocks of fixed-length"""
# chunks('ABCDEFG', 3, 'x') --> ABC DEF Gxx
args = [iter(iterable)] * size
return izip_longest(fillvalue=fill, *args)
BTW, this doesn't work as expected (at least for strings). Expected is:
chunks('ABCDEFG', 3, 'x') --> 'ABC' 'DEF' 'Gxx'
got:
chunks('ABCDEFG', 3, 'x') --> ('A' 'B' 'C') ('D' 'E' 'F') ('G' 'x' 'x')
Needs more round tuits definitely.
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [Python-ideas] itertools.chunks(iterable, size, fill=None)
anatoly techtonik, 04.07.2012 11:57:
> On Fri, Jun 29, 2012 at 11:32 PM, Georg Brandl wrote:
>> On 26.06.2012 10:03, anatoly techtonik wrote:
>>> Now that Python 3 is all about iterators (which is a user killer
>>> feature for Python according to StackOverflow -
>>> http://stackoverflow.com/questions/tagged/python) would it be nice to
>>> introduce more first class functions to work with them? One function
>>> to be exact to split string into chunks.
>>>
>>> itertools.chunks(iterable, size, fill=None)
>>>
>>> Which is the 33th most voted Python question on SO -
>>>
>>> http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python/312464
>>>
>>> P.S. CC'ing to python-dev@ to notify about the thread in python-ideas.
>>>
>>
>> Anatoly, so far there were no negative votes -- would you care to go
>> another step and propose a patch?
>
> Was about to say "no problem", but in fact - there is. Sorry from
> whining from my side and thanks for nudging. The only thought that a
> simple task of copy/pasting relevant code from
> http://docs.python.org/library/itertools.html?highlight=itertools#recipes
> will require a few hours waiting of download (still not everybody has
> a high-speed internet) makes me switch to other less time consuming
> tasks before getting around to it. These tasks become more important
> in a few hours, and basically I've passed through this many times
> before. It then becomes quite hard to switch back.
>
> I absolutely don't mind someone else being credited for the idea,
> because ideas usually worthless without implementation. It will be
> interesting to design how the process could work in a separate thread.
> For now the best thing I can do (I don't risk even to mention anything
> with 3.3) is to copy/paste code from the docs here:
>
> from itertools import izip_longest
> def chunks(iterable, size, fill=None):
> """Split an iterable into blocks of fixed-length"""
> # chunks('ABCDEFG', 3, 'x') --> ABC DEF Gxx
> args = [iter(iterable)] * size
> return izip_longest(fillvalue=fill, *args)
I think Raymond's change fixes this issue quite nicely, no need to touch at
the module code.
Stefan
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] EuroPython 2012 Language Summit Is In JEOPARDY *gasp*
So far I've had exactly four reservations for the Language Summit at EuroPython 2012. One of them is Guido--but he's threatening to skip it if we don't get more people and just go to the sprints. Also, honestly I have next-to-nothing on the docket. At this point we've just hit feature freeze for Python 3.3--or at least that's what people tell me. In general, anyone who wanted to get a language change in have already either just succeeded or just failed. So after a flurry of activity I feel like we've hit a quiet period. I mean, the trunk for 3.4 won't even be open for a month or two. So: if you're a core developer, and you're interested in attending the Language Summit in Florence on Saturday, please email me your RSVP. Also, if you have suggestions for things we should discuss, send those along too. Please send all these emails directly to me, *off-list*, tonight or Thursday. I'll send another email on Friday morning decreeing the fate of the Language Summit. Thanks! //arry/ p.s. I'm assured the room we'd have for the Language Summit has excellent air conditioning. ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [Python-ideas] itertools.chunks(iterable, size, fill=None)
On 7/4/2012 5:57 AM, anatoly techtonik wrote:
On Fri, Jun 29, 2012 at 11:32 PM, Georg Brandl wrote:
Anatoly, so far there were no negative votes -- would you care to go
another step and propose a patch?
Was about to say "no problem",
Did you read that there *are* strong negative votes? And that this idea
has been rejected before? I summarized the objections in my two
responses and pointed to the tracker issues. One of the objections is
that there are 4 different things one might want if the sequence length
is not an even multiple of the chunk size. Your original 'idea' did not
specify.
For now the best thing I can do (I don't risk even to mention anything
with 3.3) is to copy/paste code from the docs here:
from itertools import izip_longest
def chunks(iterable, size, fill=None):
"""Split an iterable into blocks of fixed-length"""
# chunks('ABCDEFG', 3, 'x') --> ABC DEF Gxx
args = [iter(iterable)] * size
return izip_longest(fillvalue=fill, *args)
Python ideas is about Python 3 ideas. Please post Python 3 code.
This is actually a one liner
return zip_longest(*[iter(iterable)]*size, fillvalue=file)
We don't generally add such to the stdlib.
BTW, this doesn't work as expected (at least for strings). Expected is:
chunks('ABCDEFG', 3, 'x') --> 'ABC' 'DEF' 'Gxx'
got:
chunks('ABCDEFG', 3, 'x') --> ('A' 'B' 'C') ('D' 'E' 'F') ('G' 'x' 'x')
One of the problems with idea of 'add a chunker' is that there are at
least a dozen variants that different people want. I discussed the
problem of return types issue in my responses. I showed how to get the
'expected' response above using grouper, but also suggested that it is
the wrong basis for splitting strings. Repeated slicing make more sense
for concrete sequence types.
def seqchunk_odd(s, size):
# include odd size left over
for i in range(0, len(s), size):
yield s[i:i+size]
print(list(seqchunk_odd('ABCDEFG', 3)))
#
['ABC', 'DEF', 'G']
def seqchunk_even(s, size):
# only include even chunks
for i in range(0, size*(len(s)//size), size):
yield s[i:i+size]
print(list(seqchunk_even('ABCDEFG', 3)))
#
['ABC', 'DEF']
def strchunk_fill(s, size, fill):
# fill odd chunks
q, r = divmod(len(s), size)
even = size * q
for i in range(0, even, size):
yield s[i:i+size]
if size != even:
yield s[even:] + fill * (size - r)
print(list(strchunk_fill('ABCDEFG', 3, 'x')))
#
['ABC', 'DEF', 'Gxx']
Because the 'fill' value is necessarily a sequence for strings,
strchunk_fill would only work for lists and tuples if the fill value
were either required to be given as a tuple or list of length 1 or if it
were internally converted inside the function. Skipping that for now.
Having written the fill version based on the even version, it is easy to
select among the three behaviors by modifying the fill version.
def strchunk(s, size, fill=NotImplemented):
# fill odd chunks
q, r = divmod(len(s), size)
even = size * q
for i in range(0, even, size):
yield s[i:i+size]
if size != even and fill is not NotImplemented:
yield s[even:] + fill * (size - r)
print(*strchunk('ABCDEFG', 3))
print(*strchunk('ABCDEFG', 3, ''))
print(*strchunk('ABCDEFG', 3, 'x'))
#
ABC DEF
ABC DEF G
ABC DEF Gxx
I already described how something similar could be done by checking each
grouper output tuple for a fill value, but that requires that the fill
value be a sentinal that could not otherwise appear in the tuple. One
could modify grouper to fill with a private object() and check the last
item of each group for that sentinal and act accordingly (delete,
truncate, or replace). A generic api needs some thought, though.
---
An issue I did not previously mention is that people sometimes want
overlapping chunks rather than contiguous disjoint chunks. The slice
approach trivially adapts to that.
def seqlap(s, size):
for i in range(len(s)-size+1):
yield s[i:i+size]
print(*seqlap('ABCDEFG', 3))
#
ABC BCD CDE DEF EFG
A sliding window for a generic iterable requires a deque or ring buffer
approach that is quite different from the zip-longest -- grouper approach.
--
Terry Jan Reedy
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
