[Python-Dev] More data points
ncoghlan at iinet.net.au
ncoghlan at iinet.net.au
Sun Sep 26 01:47:26 CEST 2004
Quoting Raymond Hettinger <python at rcn.com>:
> [Bob Ippolito]
> > > > >>> x = []
> > > > >>> x.extend(-y for y in x)
> > > > Segmentation fault
>
> I get a MemoryError.
>
> To help with get a comprehensive view when I look at this more closely
> tomorrow, can you try out variations on the theme with other mutables:
>
> myset.update
> deque.extend
> dict.update
> dict.fromkeys
> array.extend
Short answer: all of these work OK for me (i.e. do nothing). Only list.extend
suffers from the segmentation fault.
Session transcripts (with bonus X's to trick mailreaders):
[... at localhost src]$ ./python
Python 2.4a3 (#16, Sep 21 2004, 17:33:57)
[GCC 3.4.1 20040702 (Red Hat Linux 3.4.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
X>> x = []
X>> x.extend(-y for y in x)
Segmentation fault
[... at localhost src]$ ./python
Python 2.4a3 (#16, Sep 21 2004, 17:33:57)
[GCC 3.4.1 20040702 (Red Hat Linux 3.4.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
X>> x = set()
X>> x.update(-y for y in x)
X>> x
set([])
X>> from collections import deque
X>> x = deque()
X>> x.extend(-y for y in x)
X>> x
deque([])
X>> x = {}
X>> x.update(-y for y in x)
X>> x
{}
X>> x.fromkeys(-y for y in x)
{}
X>> from array import array
X>> x = array('B')
X>> x.extend(-y for y in x)
X>> x
array('B')
More information about the Python-Dev
mailing list