anon added the comment:

@Georg: I don't think it would be as common but do agree it'd be useful.

I think it can be implemented "efficiently" in pure Python currently.

def with_bits(i, value, pos, width=1):
  width = min(width, value.bit_length())
  mask = ((1 << width) - 1)
  v = value & mask
  i = i & ~(mask << pos)
  return i | (v << pos)

----------

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

Reply via email to