Repository navigation
Conversation
* Rename _PyList_AsTupleAndClear() to PyList_AsTupleAndClear(). * The function now raises TypeError if the argument is not a list. * Add documentation and tests.
Documentation build overview
|
sobolevn
left a comment
There was a problem hiding this comment.
Great stuff! This would be useful for us in msgspec's type convertion :)
| self.assertEqual(lst, []) | ||
|
|
||
| lst = [] # empty list | ||
| self.assertIs(list_as_tuple_and_clear(lst), ()) |
There was a problem hiding this comment.
question: is () being a singleton a contract or implementation detail? if the former, it would be better to compare the equality.
There was a problem hiding this comment.
Ah, that's a tricky question. It's more an implementation detail. But I would like to test this implementation detail, to check that we don't loose this optimization in a future refatoring.
|
@vstinner should we do the same with |
I found a few functions calling
So only make_union() with its I'm not sure that it's worth it to add a public PySet_AsFrozenSetAndClear() function right now. ... Also, I'm working on |
No, I would prefer to have a well-designed public API :) |
PyList_AsTupleAndClear()function #161635