[Chicago] Inheriting from a namedtuple

Mark Graves mgraves87 at gmail.com
Thu Jul 7 20:07:14 EDT 2016


It seems to me its the efficiency of creating the overhead object, and what
you are storing it in

I don't have personal benchmarks for this, but here are two resources that
helped me understand:

https://news.ycombinator.com/item?id=7230820

http://tech.oyster.com/save-ram-with-python-slots/

On Thu, Jul 7, 2016 at 4:34 PM, Aaron Elmquist <elmq0022 at umn.edu> wrote:

> Basically, I was reading someone else code (chess engine called sunfish)
> and saw this.
>
> I went back to the python namedtuple docs and saw it as an example.  So I
> know it is possible and possibly pythonic.
>
> But, I have the same question as you Adam, why not use slots instead?
>
> I am not seeing any advantages straight away.
>
> Aaron
> On Jul 7, 2016 6:20 PM, "Adam Forsyth" <adam at adamforsyth.net> wrote:
>
>> Why namedtuple instead of __slots__? What are you getting from namedtuple?
>>
>> If you do have a good reason to use namedtuple, I think it's OK to use it
>> like this -- it reads clearly to me, and is easy to refactor. However, I
>> would call the base class "PointBase" rather than "Point".
>>
>> Adam
>>
>> On Thu, Jul 7, 2016 at 5:58 PM, Aaron Elmquist <elmq0022 at umn.edu> wrote:
>>
>>> This is a very open ended question, but what do people think about
>>> python code like:
>>>
>>> class Point(namedtuple("Point", "x y")):
>>>     # additional methods here
>>>
>>> Is it pythonic?
>>>
>>> Does it buy anything besides keystrokes?
>>>
>>> Do you use it in production?
>>>
>>> Thanks,
>>>
>>> Aaron
>>>
>>> _______________________________________________
>>> Chicago mailing list
>>> Chicago at python.org
>>> https://mail.python.org/mailman/listinfo/chicago
>>>
>>>
>>
>> _______________________________________________
>> Chicago mailing list
>> Chicago at python.org
>> https://mail.python.org/mailman/listinfo/chicago
>>
>>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> https://mail.python.org/mailman/listinfo/chicago
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20160707/117990c0/attachment.html>


More information about the Chicago mailing list