Thank you for reviewing my proposal.

First and foremost, let me address the use case for this feature.  I have an 
`SQL` database where I store `itertools.cycle` objects (via pickling) and I use 
SQLAlchemy to interact with this database.  Whenever I "update" the cycler, by 
calling `next` on the cycler, SQLAlchemy detects whether or not a change has 
occurred by comparing the "new" object and the "old" object via the `__eq__` 
method to determine whether the object needs to be updated in the `SQL` 
database.  Since these objects are the still same via` __eq__` operator, no 
change is detected thus causing SQLAlchemy to no update the cycler in the 
database.

Here an example of this situation
```python
thing = session.get(Thing, 123)
# thing.cycler is the itertools.cycle object in the database
cycler = thing.cycler
value_i_want = next(cycler)
# SQLAlchemy only attempts to check if a change has occurred
# in the __setattr__ method which is why this line is here
thing.cycler = cycler
```

You bring up a good point regarding how to determine iterable equality.  For 
example, with your last example, I had no idea that the same iterable behavior 
could produce radically different results between cyclers.  To be quite honest, 
I don't really understand what causing this quirky behavior.  Perhaps this is 
more of an issue with SQLAlchemy as opposed to an issue with `itertools.cycle`. 
 Maybe somehow SQLAlchemy can insert a callback function into the __next__ 
method letting it know that in fact `thing.cycler` was updated and should be 
updated in the SQL database the next call to `session.commit()`

Anyway thank you for all your help and thorough analysis of my request!
Andres
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/FKRJIZFUBFO2V22ES3GZJMR5FN4SONSY/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to