Merge pull request #1927 from gtaylor/futures-removal

Remove Python 2.7 compatibility shims
This commit is contained in:
Griatch 2019-09-15 13:00:43 +02:00 committed by GitHub
commit ac3a8d2199
26 changed files with 30 additions and 114 deletions

View file

@ -4,7 +4,6 @@ index ec5fc29..62b7936 100644
+++ b/evennia/comms/migrations/0015_auto_20170706_2041.py +++ b/evennia/comms/migrations/0015_auto_20170706_2041.py
@@ -2,7 +2,12 @@ @@ -2,7 +2,12 @@
# Generated by Django 1.11.2 on 2017-07-06 20:41 # Generated by Django 1.11.2 on 2017-07-06 20:41
from __future__ import unicode_literals
-from django.db import migrations -from django.db import migrations
+from django.db import migrations, connection +from django.db import migrations, connection
@ -60,7 +59,6 @@ index b27c75c..6e40252 100644
+++ b/evennia/objects/migrations/0007_objectdb_db_account.py +++ b/evennia/objects/migrations/0007_objectdb_db_account.py
@@ -2,21 +2,31 @@ @@ -2,21 +2,31 @@
# Generated by Django 1.11.2 on 2017-07-05 17:27 # Generated by Django 1.11.2 on 2017-07-05 17:27
from __future__ import unicode_literals
-from django.db import migrations, models -from django.db import migrations, models
+from django.db import migrations, models, connection +from django.db import migrations, models, connection
@ -104,7 +102,6 @@ index 80161a1..10fb225 100644
+++ b/evennia/objects/migrations/0009_remove_objectdb_db_player.py +++ b/evennia/objects/migrations/0009_remove_objectdb_db_player.py
@@ -2,7 +2,12 @@ @@ -2,7 +2,12 @@
# Generated by Django 1.11.2 on 2017-07-06 20:41 # Generated by Django 1.11.2 on 2017-07-06 20:41
from __future__ import unicode_literals
-from django.db import migrations -from django.db import migrations
+from django.db import migrations, connection +from django.db import migrations, connection
@ -144,7 +141,6 @@ index 99baf70..23f6df9 100644
+++ b/evennia/scripts/migrations/0009_scriptdb_db_account.py +++ b/evennia/scripts/migrations/0009_scriptdb_db_account.py
@@ -2,21 +2,31 @@ @@ -2,21 +2,31 @@
# Generated by Django 1.11.2 on 2017-07-05 17:27 # Generated by Django 1.11.2 on 2017-07-05 17:27
from __future__ import unicode_literals
-from django.db import migrations, models -from django.db import migrations, models
+from django.db import migrations, models, connection +from django.db import migrations, models, connection
@ -188,7 +184,6 @@ index d3746a5..20fa63f 100644
+++ b/evennia/scripts/migrations/0011_remove_scriptdb_db_player.py +++ b/evennia/scripts/migrations/0011_remove_scriptdb_db_player.py
@@ -2,7 +2,12 @@ @@ -2,7 +2,12 @@
# Generated by Django 1.11.2 on 2017-07-06 20:41 # Generated by Django 1.11.2 on 2017-07-06 20:41
from __future__ import unicode_literals
-from django.db import migrations -from django.db import migrations
+from django.db import migrations, connection +from django.db import migrations, connection

View file

@ -37,7 +37,6 @@ from evennia.commands.cmdsethandler import CmdSetHandler
from evennia.utils.optionhandler import OptionHandler from evennia.utils.optionhandler import OptionHandler
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from future.utils import with_metaclass
from random import getrandbits from random import getrandbits
__all__ = ("DefaultAccount",) __all__ = ("DefaultAccount",)
@ -113,7 +112,7 @@ class AccountSessionHandler(object):
return len(self.get()) return len(self.get())
class DefaultAccount(with_metaclass(TypeclassBase, AccountDB)): class DefaultAccount(AccountDB, metaclass=TypeclassBase):
""" """
This is the base Typeclass for all Accounts. Accounts represent This is the base Typeclass for all Accounts. Accounts represent
the person playing the game and tracks account info, password the person playing the game and tracks account info, password

View file

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-01-28 18:20 # Generated by Django 1.11.16 on 2019-01-28 18:20
from __future__ import unicode_literals
import django.contrib.auth.validators import django.contrib.auth.validators
from django.db import migrations, models from django.db import migrations, models

View file

@ -26,8 +26,6 @@ Set theory.
to affect the low-priority cmdset. Ex: A1,A3 + B1,B2,B4,B5 = B2,B4,B5 to affect the low-priority cmdset. Ex: A1,A3 + B1,B2,B4,B5 = B2,B4,B5
""" """
from future.utils import listvalues, with_metaclass
from weakref import WeakKeyDictionary from weakref import WeakKeyDictionary
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from evennia.utils.utils import inherits_from, is_iter from evennia.utils.utils import inherits_from, is_iter
@ -57,7 +55,7 @@ class _CmdSetMeta(type):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
class CmdSet(with_metaclass(_CmdSetMeta, object)): class CmdSet(object, metaclass=_CmdSetMeta):
""" """
This class describes a unique cmdset that understands priorities. This class describes a unique cmdset that understands priorities.
CmdSets can be merged and made to perform various set operations CmdSets can be merged and made to perform various set operations
@ -585,7 +583,7 @@ class CmdSet(with_metaclass(_CmdSetMeta, object)):
unique[cmd.key] = cmd unique[cmd.key] = cmd
else: else:
unique[cmd.key] = cmd unique[cmd.key] = cmd
self.commands = listvalues(unique) self.commands = list(unique.values())
def get_all_cmd_keys_and_aliases(self, caller=None): def get_all_cmd_keys_and_aliases(self, caller=None):
""" """

View file

@ -64,7 +64,6 @@ example, you can have a 'On a boat' set, onto which you then tack on
the 'Fishing' set. Fishing from a boat? No problem! the 'Fishing' set. Fishing from a boat? No problem!
""" """
from builtins import object from builtins import object
from future.utils import raise_
import sys import sys
from traceback import format_exc from traceback import format_exc
from importlib import import_module from importlib import import_module
@ -172,22 +171,22 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
if not cmdsetclass: if not cmdsetclass:
try: try:
module = import_module(modpath, package="evennia") module = import_module(modpath, package="evennia")
except ImportError: except ImportError as exc:
if len(trace()) > 2: if len(trace()) > 2:
# error in module, make sure to not hide it. # error in module, make sure to not hide it.
exc = sys.exc_info() _, _, tb = sys.exc_info()
raise_(exc[1], None, exc[2]) raise exc.with_traceback(tb)
else: else:
# try next suggested path # try next suggested path
errstring += _("\n(Unsuccessfully tried '%s')." % python_path) errstring += _("\n(Unsuccessfully tried '%s')." % python_path)
continue continue
try: try:
cmdsetclass = getattr(module, classname) cmdsetclass = getattr(module, classname)
except AttributeError: except AttributeError as exc:
if len(trace()) > 2: if len(trace()) > 2:
# Attribute error within module, don't hide it # Attribute error within module, don't hide it
exc = sys.exc_info() _, _, tb = sys.exc_info()
raise_(exc[1], None, exc[2]) raise exc.with_traceback(tb)
else: else:
errstring += _("\n(Unsuccessfully tried '%s')." % python_path) errstring += _("\n(Unsuccessfully tried '%s')." % python_path)
continue continue

View file

@ -16,8 +16,6 @@ from evennia.utils.utils import is_iter, fill, lazy_property, make_iter
from evennia.utils.evtable import EvTable from evennia.utils.evtable import EvTable
from evennia.utils.ansi import ANSIString from evennia.utils.ansi import ANSIString
from future.utils import with_metaclass
def _init_command(cls, **kwargs): def _init_command(cls, **kwargs):
""" """
@ -99,7 +97,7 @@ class CommandMeta(type):
# parsing errors. # parsing errors.
class Command(with_metaclass(CommandMeta, object)): class Command(object, metaclass=CommandMeta):
""" """
Base command Base command

View file

@ -11,11 +11,11 @@ from evennia.comms.models import TempMsg, ChannelDB
from evennia.comms.managers import ChannelManager from evennia.comms.managers import ChannelManager
from evennia.utils import create, logger from evennia.utils import create, logger
from evennia.utils.utils import make_iter from evennia.utils.utils import make_iter
from future.utils import with_metaclass
_CHANNEL_HANDLER = None _CHANNEL_HANDLER = None
class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)): class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
""" """
This is the base class for all Channel Comms. Inherit from this to This is the base class for all Channel Comms. Inherit from this to
create different types of communication channels. create different types of communication channels.

View file

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-01-28 18:20 # Generated by Django 1.11.16 on 2019-01-28 18:20
from __future__ import unicode_literals
from django.conf import settings from django.conf import settings
from django.db import migrations, models from django.db import migrations, models

View file

@ -18,7 +18,6 @@ Weapon
WeaponRack WeaponRack
""" """
from future.utils import listvalues
import random import random
@ -528,7 +527,7 @@ class CmdShiftRoot(Command):
self.obj.db.root_pos = root_pos self.obj.db.root_pos = root_pos
# Check victory condition # Check victory condition
if listvalues(root_pos).count(0) == 0: # no roots in middle position if list(root_pos.values()).count(0) == 0: # no roots in middle position
# This will affect the cmd: lock of CmdPressButton # This will affect the cmd: lock of CmdPressButton
self.obj.db.button_exposed = True self.obj.db.button_exposed = True
self.caller.msg("Holding aside the root you think you notice something behind it ...") self.caller.msg("Holding aside the root you think you notice something behind it ...")

View file

@ -1,7 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-01-28 18:20 # Generated by Django 1.11.16 on 2019-01-28 18:20
from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models

View file

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-01-28 18:20 # Generated by Django 1.11.16 on 2019-01-28 18:20
from __future__ import unicode_literals
from django.conf import settings from django.conf import settings
import django.core.validators import django.core.validators

View file

@ -8,7 +8,6 @@ entities.
import time import time
import inflect import inflect
from builtins import object from builtins import object
from future.utils import with_metaclass
from collections import defaultdict from collections import defaultdict
from django.conf import settings from django.conf import settings
@ -179,7 +178,7 @@ class ObjectSessionHandler(object):
# Base class to inherit from. # Base class to inherit from.
class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): class DefaultObject(ObjectDB, metaclass=TypeclassBase):
""" """
This is the root typeclass object, representing all entities that This is the root typeclass object, representing all entities that
have an actual presence in-game. DefaultObjects generally have a have an actual presence in-game. DefaultObjects generally have a

View file

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-01-28 18:20 # Generated by Django 1.11.16 on 2019-01-28 18:20
from __future__ import unicode_literals
from django.conf import settings from django.conf import settings
from django.db import migrations, models from django.db import migrations, models

View file

@ -13,7 +13,6 @@ from evennia.typeclasses.models import TypeclassBase
from evennia.scripts.models import ScriptDB from evennia.scripts.models import ScriptDB
from evennia.scripts.manager import ScriptManager from evennia.scripts.manager import ScriptManager
from evennia.utils import create, logger from evennia.utils import create, logger
from future.utils import with_metaclass
__all__ = ["DefaultScript", "DoNothing", "Store"] __all__ = ["DefaultScript", "DoNothing", "Store"]
@ -144,7 +143,7 @@ class ExtendedLoopingCall(LoopingCall):
return None return None
class ScriptBase(with_metaclass(TypeclassBase, ScriptDB)): class ScriptBase(ScriptDB, metaclass=TypeclassBase):
""" """
Base class for scripts. Don't inherit from this, inherit from the Base class for scripts. Don't inherit from this, inherit from the
class `DefaultScript` below instead. class `DefaultScript` below instead.

View file

@ -19,7 +19,6 @@ Evennia knows which modules to use for inputfuncs by
settings.INPUT_FUNC_MODULES. settings.INPUT_FUNC_MODULES.
""" """
from future.utils import viewkeys
import importlib import importlib
from codecs import lookup as codecs_lookup from codecs import lookup as codecs_lookup

View file

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-01-28 23:11 # Generated by Django 1.11.16 on 2019-01-28 23:11
from __future__ import unicode_literals
from base64 import b64encode from base64 import b64encode
from django.db import migrations from django.db import migrations

View file

@ -3,7 +3,6 @@ This connects to an IRC network/channel and launches an 'bot' onto it.
The bot then pipes what is being said between the IRC channel and one or The bot then pipes what is being said between the IRC channel and one or
more Evennia channels. more Evennia channels.
""" """
from future.utils import viewkeys, viewvalues, viewitems
import re import re
from twisted.application import internet from twisted.application import internet
@ -90,15 +89,15 @@ IRC_COLOR_MAP = dict((
)) ))
# ansi->irc # ansi->irc
RE_ANSI_COLOR = re.compile(r"|".join( RE_ANSI_COLOR = re.compile(r"|".join(
[re.escape(key) for key in viewkeys(IRC_COLOR_MAP)]), re.DOTALL) [re.escape(key) for key in IRC_COLOR_MAP.keys()]), re.DOTALL)
RE_MXP = re.compile(r'\|lc(.*?)\|lt(.*?)\|le', re.DOTALL) RE_MXP = re.compile(r'\|lc(.*?)\|lt(.*?)\|le', re.DOTALL)
RE_ANSI_ESCAPES = re.compile(r"(%s)" % "|".join(("{{", "%%", "\\\\")), re.DOTALL) RE_ANSI_ESCAPES = re.compile(r"(%s)" % "|".join(("{{", "%%", "\\\\")), re.DOTALL)
# irc->ansi # irc->ansi
_CLR_LIST = [re.escape(val) _CLR_LIST = [re.escape(val)
for val in sorted(viewvalues(IRC_COLOR_MAP), key=len, reverse=True) if val.strip()] for val in sorted(IRC_COLOR_MAP.values(), key=len, reverse=True) if val.strip()]
_CLR_LIST = _CLR_LIST[-2:] + _CLR_LIST[:-2] _CLR_LIST = _CLR_LIST[-2:] + _CLR_LIST[:-2]
RE_IRC_COLOR = re.compile(r"|".join(_CLR_LIST), re.DOTALL) RE_IRC_COLOR = re.compile(r"|".join(_CLR_LIST), re.DOTALL)
ANSI_COLOR_MAP = dict((tup[1], tup[0]) for tup in viewitems(IRC_COLOR_MAP) if tup[1].strip()) ANSI_COLOR_MAP = dict((tup[1], tup[0]) for tup in IRC_COLOR_MAP.items() if tup[1].strip())
def parse_ansi_to_irc(string): def parse_ansi_to_irc(string):

View file

@ -14,7 +14,6 @@ There are two similar but separate stores of sessions:
""" """
import time import time
from builtins import object from builtins import object
from future.utils import listvalues
from django.conf import settings from django.conf import settings
from evennia.commands.cmdhandler import CMD_LOGINSTART from evennia.commands.cmdhandler import CMD_LOGINSTART
@ -148,7 +147,7 @@ class SessionHandler(dict):
""" """
if include_unloggedin: if include_unloggedin:
return listvalues(self) return list(self.values())
else: else:
return [session for session in self.values() if session.logged_in] return [session for session in self.values() if session.logged_in]

View file

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-01-28 18:20 # Generated by Django 1.11.16 on 2019-01-28 18:20
from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models
import evennia.utils.picklefield import evennia.utils.picklefield

View file

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-01-30 20:56 # Generated by Django 1.11.16 on 2019-01-30 20:56
from __future__ import unicode_literals
from copy import deepcopy from copy import deepcopy
from base64 import b64encode, b64decode from base64 import b64encode, b64decode

View file

@ -25,7 +25,6 @@ from evennia.utils import utils
from evennia.utils import logger from evennia.utils import logger
from evennia.utils.utils import to_str from evennia.utils.utils import to_str
from future.utils import with_metaclass
# ANSI definitions # ANSI definitions
@ -631,7 +630,7 @@ class ANSIMeta(type):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
class ANSIString(with_metaclass(ANSIMeta, str)): class ANSIString(str, metaclass=ANSIMeta):
""" """
Unicode-like object that is aware of ANSI codes. Unicode-like object that is aware of ANSI codes.

View file

@ -111,8 +111,6 @@ table string.
""" """
from future.utils import listitems
from django.conf import settings from django.conf import settings
from textwrap import TextWrapper from textwrap import TextWrapper
from copy import deepcopy, copy from copy import deepcopy, copy
@ -1464,7 +1462,7 @@ class EvTable(object):
""" """
# this will replace default options with new ones without changing default # this will replace default options with new ones without changing default
options = dict(listitems(self.options) + listitems(kwargs)) options = dict(list(self.options.items()) + list(kwargs.items()))
xpos = kwargs.get("xpos", None) xpos = kwargs.get("xpos", None)
column = EvColumn(*args, **options) column = EvColumn(*args, **options)
@ -1529,7 +1527,7 @@ class EvTable(object):
""" """
# this will replace default options with new ones without changing default # this will replace default options with new ones without changing default
row = list(args) row = list(args)
options = dict(listitems(self.options) + listitems(kwargs)) options = dict(list(self.options.items()) + list(kwargs.items()))
ypos = kwargs.get("ypos", None) ypos = kwargs.get("ypos", None)
wtable = self.ncols wtable = self.ncols

View file

@ -8,7 +8,6 @@ Also adds `cache_size()` for monitoring the size of the cache.
""" """
from builtins import object from builtins import object
from future.utils import listitems, listvalues, with_metaclass
import os import os
import threading import threading
@ -197,7 +196,7 @@ class SharedMemoryModelBase(ModelBase):
return return
# dynamically create the wrapper properties for all fields not already handled # dynamically create the wrapper properties for all fields not already handled
# (manytomanyfields are always handlers) # (manytomanyfields are always handlers)
for fieldname, field in ((fname, field) for fname, field in listitems(attrs) for fieldname, field in ((fname, field) for fname, field in list(attrs.items())
if fname.startswith("db_") and type(field).__name__ != "ManyToManyField"): if fname.startswith("db_") and type(field).__name__ != "ManyToManyField"):
foreignkey = type(field).__name__ == "ForeignKey" foreignkey = type(field).__name__ == "ForeignKey"
wrappername = "dbid" if fieldname == "id" else fieldname.replace("db_", "", 1) wrappername = "dbid" if fieldname == "id" else fieldname.replace("db_", "", 1)
@ -208,7 +207,7 @@ class SharedMemoryModelBase(ModelBase):
return super().__new__(cls, name, bases, attrs) return super().__new__(cls, name, bases, attrs)
class SharedMemoryModel(with_metaclass(SharedMemoryModelBase, Model)): class SharedMemoryModel(Model, metaclass=SharedMemoryModelBase):
""" """
Base class for idmapped objects. Inherit from `this`. Base class for idmapped objects. Inherit from `this`.
""" """
@ -291,7 +290,7 @@ class SharedMemoryModel(with_metaclass(SharedMemoryModelBase, Model)):
Return the objects so far cached by idmapper for this class. Return the objects so far cached by idmapper for this class.
""" """
return listvalues(cls.__dbclass__.__instance_cache__) return list(cls.__dbclass__.__instance_cache__.values())
@classmethod @classmethod
def _flush_cached_by_key(cls, key, force=True): def _flush_cached_by_key(cls, key, force=True):
@ -457,7 +456,7 @@ class WeakSharedMemoryModelBase(SharedMemoryModelBase):
cls.__dbclass__.__instance_cache__ = WeakValueDictionary() cls.__dbclass__.__instance_cache__ = WeakValueDictionary()
class WeakSharedMemoryModel(with_metaclass(WeakSharedMemoryModelBase, SharedMemoryModel)): class WeakSharedMemoryModel(SharedMemoryModel, metaclass=WeakSharedMemoryModelBase):
""" """
Uses a WeakValue dictionary for caching instead of a regular one Uses a WeakValue dictionary for caching instead of a regular one

View file

@ -6,9 +6,8 @@ They provide some useful string and conversion methods that might
be of use when designing your own game. be of use when designing your own game.
""" """
from future.utils import viewkeys, raise_
import os import os
import gc
import sys import sys
import imp import imp
import types import types
@ -35,14 +34,6 @@ from evennia.utils import logger
_MULTIMATCH_TEMPLATE = settings.SEARCH_MULTIMATCH_TEMPLATE _MULTIMATCH_TEMPLATE = settings.SEARCH_MULTIMATCH_TEMPLATE
_EVENNIA_DIR = settings.EVENNIA_DIR _EVENNIA_DIR = settings.EVENNIA_DIR
_GAME_DIR = settings.GAME_DIR _GAME_DIR = settings.GAME_DIR
# ModuleNotFoundError only in py3.6, handle both
try:
from builtins import ModuleNotFoundError
except ImportError:
ModuleNotFoundError = ImportError
ENCODINGS = settings.ENCODINGS ENCODINGS = settings.ENCODINGS
_GA = object.__getattribute__ _GA = object.__getattribute__
_SA = object.__setattr__ _SA = object.__setattr__
@ -1052,45 +1043,6 @@ def delay(timedelay, callback, *args, **kwargs):
return _TASK_HANDLER.add(timedelay, callback, *args, **kwargs) return _TASK_HANDLER.add(timedelay, callback, *args, **kwargs)
_TYPECLASSMODELS = None
_OBJECTMODELS = None
def clean_object_caches(obj):
"""
Clean all object caches on the given object.
Args:
obj (Object instace): An object whose caches to clean.
Notes:
This is only the contents cache these days.
"""
global _TYPECLASSMODELS, _OBJECTMODELS
if not _TYPECLASSMODELS:
from evennia.typeclasses import models as _TYPECLASSMODELS
if not obj:
return
# contents cache
try:
_SA(obj, "_contents_cache", None)
except AttributeError:
# if the cache cannot be reached, move on anyway
pass
# on-object property cache
[_DA(obj, cname) for cname in viewkeys(obj.__dict__)
if cname.startswith("_cached_db_")]
try:
hashid = _GA(obj, "hashid")
_TYPECLASSMODELS._ATTRIBUTE_CACHE[hashid] = {}
except AttributeError:
# skip caching
pass
_PPOOL = None _PPOOL = None
_PCMD = None _PCMD = None
_PROC_ERR = "A process has ended with a probable error condition: process ended by signal 9." _PROC_ERR = "A process has ended with a probable error condition: process ended by signal 9."
@ -1693,10 +1645,6 @@ def get_evennia_pids():
return None, None return None, None
from gc import get_referents
from sys import getsizeof
def deepsize(obj, max_depth=4): def deepsize(obj, max_depth=4):
""" """
Get not only size of the given object, but also the size of Get not only size of the given object, but also the size of
@ -1722,14 +1670,14 @@ def deepsize(obj, max_depth=4):
def _recurse(o, dct, depth): def _recurse(o, dct, depth):
if 0 <= max_depth < depth: if 0 <= max_depth < depth:
return return
for ref in get_referents(o): for ref in gc.get_referents(o):
idr = id(ref) idr = id(ref)
if idr not in dct: if idr not in dct:
dct[idr] = (ref, getsizeof(ref, default=0)) dct[idr] = (ref, sys.getsizeof(ref, default=0))
_recurse(ref, dct, depth + 1) _recurse(ref, dct, depth + 1)
sizedict = {} sizedict = {}
_recurse(obj, sizedict, 0) _recurse(obj, sizedict, 0)
size = getsizeof(obj) + sum([p[1] for p in sizedict.values()]) size = sys.getsizeof(obj) + sum([p[1] for p in sizedict.values()])
return size return size

View file

@ -5,7 +5,6 @@ django >= 2.2.5, < 2.3
twisted >= 19.2.1, < 20.0.0 twisted >= 19.2.1, < 20.0.0
pillow == 5.2.0 pillow == 5.2.0
pytz pytz
future >= 0.15.2
django-sekizai django-sekizai
inflect inflect
autobahn >= 17.9.3 autobahn >= 17.9.3

View file

@ -8,7 +8,6 @@ django >= 2.2.5, < 2.3
twisted >= 19.2.1, < 20.0.0 twisted >= 19.2.1, < 20.0.0
pillow == 5.2.0 pillow == 5.2.0
pytz pytz
future >= 0.15.2
django-sekizai django-sekizai
autobahn >= 17.9.3 autobahn >= 17.9.3
inflect inflect