Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111605
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: can't add variables to instances of built-in classes |
| Date | 2016-07-18 06:10 -0700 |
| Message-ID | <mailman.74.1468847389.2307.python-list@python.org> (permalink) |
| References | <4f796d95-0e87-4610-a0a8-1eff07c60ace@googlegroups.com> <nmfqrg$ea7$1@ger.gmane.org> <mailman.63.1468755660.2307.python-list@python.org> <b24bede0-be29-4c45-856e-90e6a63c99d0@googlegroups.com> <578CD530.5090702@stoneleaf.us> |
On 07/17/2016 04:50 AM, Wilson Ong wrote: >> Use this feature sparingly, only when you know that there are going to be >> many (millions rather than thousands) of Test instances. > > Why use it sparingly? Is it for extensibility? What if I'm pretty sure that > my class is going to have exactly these attributes only? One of the very nice things about Python is being able to fiddle with objects, both for debugging and for extending. One of the ways that's accomplished is by adding attributes to instances, but when __slots__ is defined that ability is lost, which can make using/debugging those types of objects harder. __slots__ is a memory optimization, and like most optimazations you shouldn't use it until you know you need it. -- ~Ethan~
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
can't add variables to instances of built-in classes Kent Tong <kent.tong.mo@gmail.com> - 2016-07-17 03:57 -0700
Re: can't add variables to instances of built-in classes Peter Otten <__peter__@web.de> - 2016-07-17 13:40 +0200
Re: can't add variables to instances of built-in classes Wilson Ong <wilsonokw@gmail.com> - 2016-07-17 04:50 -0700
Re: can't add variables to instances of built-in classes Chris Angelico <rosuav@gmail.com> - 2016-07-17 22:02 +1000
Re: can't add variables to instances of built-in classes Steven D'Aprano <steve@pearwood.info> - 2016-07-18 01:04 +1000
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-17 20:00 -0700
Re: can't add variables to instances of built-in classes Peter Otten <__peter__@web.de> - 2016-07-18 09:38 +0200
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-18 14:48 -0700
Re: can't add variables to instances of built-in classes breamoreboy@gmail.com - 2016-07-18 16:12 -0700
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-18 19:53 -0700
Re: can't add variables to instances of built-in classes breamoreboy@gmail.com - 2016-07-19 14:24 -0700
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-19 16:58 -0700
Re: can't add variables to instances of built-in classes Chris Angelico <rosuav@gmail.com> - 2016-07-20 16:19 +1000
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-19 23:45 -0700
Re: can't add variables to instances of built-in classes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-07-20 17:22 +1000
Re: can't add variables to instances of built-in classes Peter Otten <__peter__@web.de> - 2016-07-20 09:26 +0200
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-20 01:50 -0700
Re: can't add variables to instances of built-in classes Peter Otten <__peter__@web.de> - 2016-07-20 11:15 +0200
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-20 15:11 -0700
Re: can't add variables to instances of built-in classes Chris Angelico <rosuav@gmail.com> - 2016-07-21 12:29 +1000
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-08-03 19:34 -0700
Re: can't add variables to instances of built-in classes Chris Angelico <rosuav@gmail.com> - 2016-08-04 13:00 +1000
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-08-04 16:57 -0700
Re: can't add variables to instances of built-in classes Steven D'Aprano <steve@pearwood.info> - 2016-07-21 12:48 +1000
Re: can't add variables to instances of built-in classes Steven D'Aprano <steve@pearwood.info> - 2016-07-20 22:10 +1000
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-20 14:48 -0700
Re: can't add variables to instances of built-in classes breamoreboy@gmail.com - 2016-07-20 18:04 -0700
Re: can't add variables to instances of built-in classes Peter Otten <__peter__@web.de> - 2016-07-21 08:59 +0200
Re: can't add variables to instances of built-in classes Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-20 02:10 -0700
Re: can't add variables to instances of built-in classes Ethan Furman <ethan@stoneleaf.us> - 2016-07-18 06:10 -0700
Re: can't add variables to instances of built-in classes Kent Tong <kent.tong.mo@gmail.com> - 2016-07-17 04:53 -0700
csiph-web