Why has Python decided against constant references? -


note: i'm not talking preventing rebinding of variable. i'm talking preventing modification of memory variable refers to, , of memory can reached there following nested containers.

i have large data structure, , want expose other modules, on read-only basis. way in python deep-copy particular pieces i'd expose - prohibitively expensive in case.

i sure common problem, , seems constant reference perfect solution. must missing something. perhaps constant references hard implement in python. perhaps don't quite think do.

any insights appreciated.


while answers helpful, haven't seen single reason why const either hard implement or unworkable in python. guess "un-pythonic" count valid reason, really? python scrambling of private instance variables (starting __) avoid accidental bugs, , const doesn't seem different in spirit.


edit: offered modest bounty. looking bit more detail why python ended without const. suspect reason it's hard implement work perfectly; understand why it's hard.

in pep 351, barry warsaw proposed protocol "freezing" mutable data structure, analogous way frozenset makes immutable set. frozen data structures hashable , capable being used keys in dictionaries.

the proposal discussed on python-dev, raymond hettinger's criticism detailed.

it's not quite you're after, it's closest can find, , should give idea of thinking of python developers on subject.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -