-
Notifications
You must be signed in to change notification settings - Fork 37
Fixed Player.is_bot to be cached correctly. #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jordanbriere
merged 1 commit into
Source-Python-Dev-Team:cached_property
from
CookStar:cached_property
Dec 11, 2019
Merged
Fixed Player.is_bot to be cached correctly. #294
jordanbriere
merged 1 commit into
Source-Python-Dev-Team:cached_property
from
CookStar:cached_property
Dec 11, 2019
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ayuto
pushed a commit
that referenced
this pull request
Jun 20, 2020
* Added cached properties implementation. * Fixed cached generators being exhausted after the first iteration. * Fixed CachedGenerator not caching all the generated values if the first to request the property was stopping the iteration early. * Dynamic entity functions are now cached. * Added Entity.instances cached property. * Entity.inputs and Entity.outputs instances are now cached. Removed Entity.instances. Entity.inputs, Entity.outputs and Entity.server_classes are now returning dictionaries mapping their instances rather than iterators generating their names. * Improved performance of Entity.<get/set>_property_<type> methods. Fixed BaseEntity.<get/set>_network_property_<type> from reading/writing from a NULL pointer. Fixed excluded properties/collapsible tables not being skipped. * Fixed some memory leaks. * Fixed CachedProperty's decorators overriding the main descriptor name. Removed CachedGenerator as caching it was leaking a shallow copy of the entire frame. The generated values are now computed and cached on retrieval, rather than iteration. Improved the logic of CachedProperty.__get__. Removed some redundant cast/extract between CPython and Boost. Fixed some exceptions being silenced under certain conditions within the load/unload process. * EntityMemFuncWrapper is no longer caching itself; the Entity class already takes care of it. * Fixed Player.is_bot and Player.is_hltv now being properties rather than function which was breaking existing code. Added BaseEntity.entity_flags. Fixed EntityMemFuncWrapper no longer overwriting the cache resulting into them no longer being called. Fixed an issue when entities instances were cached again after we invalidated the cache. * Improved the caching of dynamic function wrappers. * Fixed a circular reference. * Fixed cached properties declared on the c++ side not being managed by Python. * Removed CachedProperty.owner, which was causing another circular reference because it was referring to the class the property itself is bound to. * Fixed back reference issues. * Fixed KeyError when invalidating the cache for field that were not previously requested. * Fixed EntityDictionary potentially caching soon-to-be removed entities. * Added a warning to CachedProperty's documentation regarding circular references. Updated some docstrings. * Fixed dynamic function wrappers from no longer being documented. * Fixed Entity.__setattr__ not properly iterating over the entity's server classes. Fixed dynamic function wrappers from no longer being able to access the instance. Some various improvements to some redundant logics. * Added "unbound" parameter to CachedProperty as a workaround for circular references. Entity.__hash__ now hashes its inthandle rather than its index (the later can be reused and match a new entity later on, while the former doesn't seems to be ever re-used from my testing). * Added back CachedProperty.owner as a weak reference. Reverted EntityMemFuncWrapper back to be bound and store a proxy of the wrapped instance. My tests were not leaking because the hash was matching so the cache was re-used but no matter where we cache the value, it will still keep the instance hostage if it strongly refers it. Left the unbound implementation in place, as it can be useful in other cases. Added unbound parameter to CachedProperty.wrap_descriptor. Updated docstrings and signatures. * Fixed Player.is_bot to be cached correctly. (#294) Fixed Player.is_bot to be cached correctly. * Fixed a crash caused by Function's convention being freed twice when Source.Python is unloading. * Fixed the invalidation of the internal entity cache before all entity deletion listeners were called. Fixed a KeyError being silenced in EntityDictionary.on_automatically_removed overrides. Slightly improved the retrieval speed of the cached entity instances. * Added caching boolean argument for Player.from_userid. * Disabled instance caching for Entity's subclasses that do not explicitly enable it (to retain backward compatibility for existing classes that were not implemented with caching in mind). Added caching keyword to Entity.from_inthandle. Fixed Player.from_userid not following the caching state of the current class unless explicitly specified. Added missing documentation. * Improved performance of memory tools (approximately 2.5 times faster). * Fixed exceptions potentially being silenced when caching generators. * Added missing args and kwargs parameters to CachedProperty.wrap_descriptor. * Moved an extraction to avoid doing it when not necessary. * Optimized Entity.<get/set>_property_edict methods. Removed Entity._<get/set>_property methods. * Fixed entity delays/repeats not being cancelled if they were registered from an OnEntityDeleted listener called after the internal callback. * Player.language property is now only cached for games it was already cached. * Optimized non-cached get_client_language by using the internal Player cache instead of PlayerInfo. * Optimized various python calls from c++. * Optimized pointer extraction. * Fixed memory leaks caused by Sound/StreamSound instances never unloaded when instantiated from Entity.emit_sound. * Fixed memory leaks into engine_sound.emit_sound caused by the sounds not being emitted through the reliable channel. * Improved performance of Entity.is_in_solid's default behaviour (approx. 19 times faster). * Moved Entity.<get/set>_property_<type> methods to BaseEntity (approx. ~3 times faster). Added BaseEntity.<get/set>_<datamap/network>_property_edict. Added BaseEntity.get_property_double. Added BaseEntity.get_property_long. Added BaseEntity.get_property_long_long. Added BaseEntity.get_property_string_array. Added BaseEntity.get_property_ulong. Added BaseEntity.get_property_ulong_long. Added BaseEntity.set_property_double. Added BaseEntity.set_property_long. Added BaseEntity.set_property_long_long. Added BaseEntity.set_property_string_array. Added BaseEntity.set_property_ulong. Added BaseEntity.set_property_ulong_long. * Removed Entity.<get/set>_property_<type> methods. * Improved performance of TraceFilterSimple.should_hit_entity (approx. 42 times faster). * Oops, fixed a condition. * Added example to CachedProperty's docstring. Fixed a typo into CachedProperty.__delete__'s docstring. * Improved performance of Entity.create, find and find_or_create by moving them to BaseEntity directly. * Fixed non-networked entities creation/lookup. * Added an overload to memory.make_object to avoid redundant extraction. * Added BaseEntity.is_marked_for_deletion (approx. 13 times faster than the manual check). * Fixed BaseEntity.is_marked_for_deletion from checking the wrong flag. * Moved InputFunction to c++ (~21x faster). * Added sanity check to InputFunction's constructor. Added missing entries to entities.datamaps.__all__. Updated InputFunction's documentation. * Removed no longer used imports into entities._base. * Added cached_result decorator. * Removed a redundant layer to get Entity.index. Removed some redundant extractions to get/set CachedProperty.__doc__. Fixed some docstrings. * Added CachedProperty.<get/set>_cached_value methods. * Fixed CachedProperty.<get/set>_cached_value methods from possibly caching the value of an unbound property. Fixed CachedProperty.set_cached_value not properly handling generators. * Improved some Entity's methods by avoiding repeated attribute retrievals. Co-authored-by: Jonathan <[email protected]> Co-authored-by: satoon101 <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix to 9c7e4a2