@@ -67,6 +67,18 @@ class Item(STACObject, Assets):
6767            :attr:`~pystac.Asset.owner` attribute set to the created Item. 
6868    """ 
6969
70+     __slots__ : tuple [str , ...] =  STACObject .__slots__  +  (
71+         "assets" ,
72+         "bbox" ,
73+         "collection" ,
74+         "collection_id" ,
75+         "datetime" ,
76+         "extra_fields" ,
77+         "geometry" ,
78+         "links" ,
79+         "properties" ,
80+     )
81+ 
7082    assets : dict [str , Asset ]
7183    """Dictionary of :class:`~pystac.Asset` objects, each with a unique key.""" 
7284
@@ -157,7 +169,8 @@ def __init__(
157169        if  href  is  not   None :
158170            self .set_self_href (href )
159171
160-         self .collection_id : str  |  None  =  None 
172+         self .collection_id  =  None 
173+         self .collection  =  None 
161174        if  collection  is  None :
162175            self .collection  =  None 
163176        else :
@@ -175,30 +188,34 @@ def __repr__(self) -> str:
175188        return  f"<Item id={ self .id }  >" 
176189
177190    def  __getstate__ (self ) ->  dict [str , Any ]:
178-         """Ensure that pystac does not encode too much information when pickling""" 
179-         d  =  self . __dict__ . copy () 
191+         """Ensure that pystac does not encode too much information when pickling. """ 
192+         state  =  { slot :  getattr ( self ,  slot )  for   slot   in   self . __slots__ } 
180193
181-         d ["links" ] =  [
194+         state ["links" ] =  [
182195            (
183196                link .to_dict (transform_href = False )
184197                if  link .get_href (transform_href = False )
185198                else  link 
186199            )
187-             for  link  in  d ["links" ]
200+             for  link  in  state ["links" ]
188201        ]
189202
190-         return  d 
203+         return  state 
191204
192205    def  __setstate__ (self , state : dict [str , Any ]) ->  None :
193206        """Ensure that pystac knows how to decode the pickled object""" 
194-         d  =  state .copy ()
195- 
196-         d ["links" ] =  [
197-             Link .from_dict (link ).set_owner (self ) if  isinstance (link , dict ) else  link 
198-             for  link  in  d ["links" ]
199-         ]
207+         for  slot  in  self .__slots__ :
208+             if  slot  ==  "links" :
209+                 value  =  [
210+                     Link .from_dict (link ).set_owner (self )
211+                     if  isinstance (link , dict )
212+                     else  link 
213+                     for  link  in  state ["links" ]
214+                 ]
215+             else :
216+                 value  =  state .get (slot )  # type: ignore 
200217
201-         self . __dict__   =   d 
218+              setattr ( self ,  slot ,  value ) 
202219
203220    def  set_self_href (self , href : str  |  None ) ->  None :
204221        """Sets the absolute HREF that is represented by the ``rel == 'self'`` 
0 commit comments