<div dir="ltr">Sorry, I don't quite follow.<br><br><div class="gmail_quote"><div dir="ltr">On Thu, 21 Jun 2018 at 08:50 Christian Tismer <<a href="mailto:tismer@stackless.com">tismer@stackless.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi friends,<br>
<br>
there is a case in the Python API where I am not sure what to do:<br>
<br>
If an object defines __getitem__() only but no __len__(),<br>
then PySequence_Check() already is true and does not care.<br></blockquote><div><br></div><div>Which matches <a href="https://docs.python.org/3/c-api/sequence.html#c.PySequence_Check">https://docs.python.org/3/c-api/sequence.html#c.PySequence_Check</a> .</div><div><br></div><div>From Objects/abstract.c:</div><div><br></div><div>int<br>PySequence_Check(PyObject *s)<br>{<br>    if (PyDict_Check(s))<br>        return 0;<br>    return s != NULL && s->ob_type->tp_as_sequence &&<br>        s->ob_type->tp_as_sequence->sq_item != NULL;<br>}</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
So if I define no __len__, it simply fails. Is this intended?<br></blockquote><div><br></div><div>What is "it" in this case that is failing? It isn't PySequence_Check() so I'm not sure what the issue is.</div><div><br></div><div>-Brett<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I was mislead and thought this was the unlimited case, but<br>
it seems still to be true that sequences are always finite.<br>
<br>
Can someone please enlighten me?<br>
-- <br>
Christian Tismer-Sperling    :^)   <a href="mailto:tismer@stackless.com" target="_blank">tismer@stackless.com</a><br>
Software Consulting          :     <a href="http://www.stackless.com/" rel="noreferrer" target="_blank">http://www.stackless.com/</a><br>
Karl-Liebknecht-Str. 121     :     <a href="http://pyside.org" rel="noreferrer" target="_blank">http://pyside.org</a><br>
14482 Potsdam                :     GPG key -> 0xE7301150FB7BEE0E<br>
phone <a href="tel:+49%20173%202418776" value="+491732418776" target="_blank">+49 173 24 18 776</a>  fax <a href="tel:+49%2030%207001430023" value="+49307001430023" target="_blank">+49 (30) 700143-0023</a><br>
<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/brett%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/brett%40python.org</a><br>
</blockquote></div></div>