[issue36507] frozenset type breaks ZFC

2019-04-02 Thread George Shuklin


New submission from George Shuklin :

ZFC (https://en.wikipedia.org/wiki/Zermelo%E2%80%93Fraenkel_set_theory) defines 
numbers as nested empty sets.

0 is {}
1 is {{}}
2 is {{{}}}

Sets can not be nested in python (as they are mutable), so next best type is 
frozen set. Unfortunately, nested sets are equal to each other no matter how 
deep they are nested. This behavior means that 3==2, and it breaks all set 
operations for ZFC.

Minimal example:

frozenset({frozenset()})
>>> x=frozenset()
>>> y=frozenset(frozenset())
>>> x is y
True

--
components: Interpreter Core
messages: 339340
nosy: george-shuklin
priority: normal
severity: normal
status: open
title: frozenset type breaks ZFC
type: behavior
versions: Python 3.7

___
Python tracker 
<https://bugs.python.org/issue36507>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30734] 200000 indexes crashes eval and python (without eval)

2017-06-25 Thread George Shuklin

George Shuklin added the comment:

Unfixed crash of code interpreter? This is sad.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30734>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30734] 200000 indexes crashes eval and python (without eval)

2017-06-22 Thread George Shuklin

New submission from George Shuklin:

If there is too many indexes python crashes:

a[0][0][0][0]

segfault at 7ffd25fe6ff8 ip 564528c8cfe6 sp 7ffd25fe7000 error 6 in 
python2.7[564528b6a000+324000]

code to generate code:

>>> i="[0]"*20
>>> file('/tmp/bad_python.py','w').write('a=[]\na.append(a)\nprint(type(a'+i+'))\n')

python2 /tmp/bad_python.py 
Segmentation fault (core dumped)

python3 /tmp/bad_python.py 
RecursionError: maximum recursion depth exceeded during compilation

Just in case I upload generated code.

This bug affects both eval() function and python interpreter.

--
components: Interpreter Core
files: bad_python.py.gz
messages: 296626
nosy: george-shuklin
priority: normal
severity: normal
status: open
title: 20 indexes crashes eval and python (without eval)
type: crash
versions: Python 2.7
Added file: http://bugs.python.org/file46968/bad_python.py.gz

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30734>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29511] Add 'find' as build-in method for lists

2017-02-09 Thread George Shuklin

New submission from George Shuklin:

I found that Python provides 'find()' and 'in' methods for strings, but lacking 
same functionality for lists.

Because strings and lists are very similar, it's reasonable to expect same 
function available for both.

Here long and rather ugly hack list on stackoverflow about 'reinventing the 
wheel': 
http://stackoverflow.com/questions/16579085/python-verifying-if-one-list-is-a-subset-of-the-other

There are short few proposals, each of them imperfect:
1. Use sets intersection. This looses count and order
2. Use collections.Count. This looses order
3. all(x in two for x in one) - looses order

Propsal: adds a normal 'find' method which will behave the same way as find for 
strings. It should perform normal __cmp__ call on each element, or, may be, 
asking for optional lambda to perform comparison of elements.

--
components: Interpreter Core
messages: 287394
nosy: george-shuklin
priority: normal
severity: normal
status: open
title: Add 'find' as build-in method for lists
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29511>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com