Skip to content

Commit 777f636

Browse files
committed
Make stringdtype.NA a singleton so pickle doesn't create new instances
1 parent 676c2fd commit 777f636

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

stringdtype/stringdtype/missing.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
class NAType:
1+
class Singleton:
2+
_instance = None
3+
4+
def __new__(cls):
5+
if cls._instance is None:
6+
cls._instance = super().__new__(cls)
7+
return cls._instance
8+
9+
10+
class NAType(Singleton):
211
def __repr__(self):
312
return "stringdtype.NA"
413

0 commit comments

Comments
 (0)