# Mutating immutable objects with ctypes

**URL:** <https://discuss.python.org/t/mutating-immutable-objects-with-ctypes/43724>\
**Category:** Python Help\
**Created:** [January 20, 2024, 2:41pm UTC](https://discuss.python.org/t/mutating-immutable-objects-with-ctypes/43724 "2024-01-20T14:41:56Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![tjreedy](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tjreedy/32/137_2.png) [@tjreedy](https://discuss.python.org/u/tjreedy)\
**Post date:** [January 20, 2024, 8:38pm UTC](https://discuss.python.org/t/mutating-immutable-objects-with-ctypes/43724/4 "2024-01-20T20:38:28Z")

</div>

> [@Is this meant to be an expected behavior?](https://discuss.python.org/t/is-this-meant-to-be-an-expected-behavior/43679/5):
>
> > [@Is this meant to be an expected behavior?](https://discuss.python.org/t/is-this-meant-to-be-an-expected-behavior/43679/5):
> >
> > there is no way from within Python to modify the integer object itself
> 
> [Actually…](https://stackoverflow.com/q/70882092)

To me, this ‘gotcha’ comment is not only a distraction from the subject of the thread, but is wrong. @kknechtel said “within Python”. The SO answer uses the CPython implementation’s interface to foreign _non-Python_ functions. So “within CPython with cytpes or similar non-Python function access allowed, int object values can be mutated”. Karl, please feel free to write sensibly, as you did, without adding a caveat to every comment.

Most every statement in the _Python_ docs _inplicitly_ assumes that one has not called an implementation-specific foreign function that contradicts the statement. The docs effectively describe Python behavior on a pure Python interpreter that does not have such possibilities. Github python/cpython Issues that report “by using ctypes I made CPython misbehave” get rejected and closed.

---

_[View the full topic](https://discuss.python.org/t/mutating-immutable-objects-with-ctypes/43724)._
