Skip to content

Releases: hikari-py/hikari

Configurable cache

14 Jan 12:49
23a57e9
Compare
Choose a tag to compare
Configurable cache Pre-release
Pre-release

Breaking changes

  • RestAware does not include CacheAware anymore
  • Guild chunker removed
  • PartialMessage.reply renamed to PartialMessage.respond
  • reply_message arg renamed to reply
  • reply_mention arg renamed to mentions_reply
  • PresenceUpdateEvent.get_cached_user renamed to PresenceUpdateEvent.get_user
  • Documentation has been moved from https://hikari-py.github.io/hikari/hikari to https://hikari-py.github.io/hikari/documentation
  • chunking_limit and enable_cache args removed from BotImpl
    • To retain the functionality of enable_cache, please use BotImpl(cache_settings=CacheSttings(enable=False))

Features

  • source_channel and source_guild have been added to Webhook
  • Guild template objects and endpoints
  • Member.is_pending attribute added
  • Member.roles property added
  • applications.TeamMember now extends users.User
  • Twemoji base url has been switched to raw.githubusercontent.com to avoid redirects
  • Stateful and stateless components merged
  • Message.respond can take in reply as True to reply to the message
  • GuildAvailableEvent now includes a guild_chunk_nonce attribute to aid tracking chunks
  • CacheImpl rewritten internally
    • Fully configurable (hikari.config.CacheSettings)
    • Allow snowflakes.Snowflakeish to be used for IDs in calls to cache

Bugfixes

  • Improve handling websocket disconnects
  • Mobile friendly landing page
  • OwnUser.send now matches the inherited signature
  • mentions_reply added to edit_message
  • PyPI checker now recomends you to update dev releases
  • Voice state now correctly updates (muting and deafening)
  • Cache now cleared out on bot closure
  • .channel properties failing to assert when None

Role tags and dm flow

11 Dec 09:53
a0fff5c
Compare
Choose a tag to compare
Role tags and dm flow Pre-release
Pre-release

Breaking Changes

None :)

Features

  • DM flow on user objects
  • Better __str__ for BulkDeleteError

Package bumps

  • multidict (5.0.2 -> 5.1.0)

Gateway and component bugfixes

02 Dec 19:08
059b10c
Compare
Choose a tag to compare
Pre-release
  • New error ComponentNotRunningError that will be raised when trying to interact with a component that is not running
  • Actually closing when one of the shards has been manually shut down
  • sent_close not being set when calling send_close
  • Unused ratelimiter now hooked up to prevent getting disconnected on too many requests
  • bot.shards is now populated as soon as the shard object is created to be able to be used through bot.x on shard events

Inline replies support and `old_x` on update and delete events

29 Nov 13:57
6c53b3a
Compare
Choose a tag to compare

Breaking changes

  • rest.create_crossposts has been renamed to rest.crosspost_message
  • MessageCrosspost renamed to MessageRefence

Features

  • New webhook endpoints to interact with messages sent by webhooks
    • rest.edit_webhook_message
    • rest.delete_webhook_message
  • old_x fields on objects that are sent on XUpdateEvent and XDeleteEvent
    • This requires the cache to be enabled and the info to be available. If not, old_x will be None.
  • Cache configuration is now possible by using BotApp(cache_settings=...)
  • Message cache
    • Configurable by using hikari.config.CacheSettings
  • Logging fixes
  • New speedup (brotli)

Bugfixes

  • bot.heartbeat_latency returning the sum of all shard latencies instead of the average
  • bot.wait_for not removing waiter from the set on timeout
  • Switch to using x-ratelimit-reset-after as reset_after for more precision
    • Add reactions endpoint should be faster now

Package version bumps

  • aiohttp (3.7.2 -> 3.7.3)
  • brotli (1.0.7 -> 1.0.9) [speedups] SECURITY BUG, PLEASE UPDATE IF YOU ARE USING IT

Ratelimits fixes and new models

15 Nov 09:27
5a2c071
Compare
Choose a tag to compare
Pre-release

Breaking changes

  • Message mentions have been moved to Message.mentions as a Mentions object to provide more functionality

Features

  • GuildMember.ban is now implemented
  • Prebuilt documentation indexes for faster loading times
  • New rest.search_members endpoint

Bug fixes

  • Running expensive logging functions when logging was not enabled
    • This slowed down requests, which wont happen now.
  • Implemented a lock on requests which only allows 1 simultaneous request to aid ratelimiting
    • Should help bots which use a lot 1 single endpoint, as there will be no more 429's

Package version bumps

  • attrs (20.2.0 -> 20.3.0)
  • colorlog (4.4.0 -> 4.6.2)
  • multidict (5.0.0 -> 5.0.2)

Correct shard and bot closing

30 Oct 10:29
0a41cb6
Compare
Choose a tag to compare
Pre-release

Breaking changes

  • Removed PUBLIC and PUBLIC_DISABLED flags from guild features and they have been replaced by COMMUNITY and DISCOVERABLE

Features

  • New JSON Codes
  • Bot and webhook integrations objects + endpoints
    • New IntegrationType and IntegrationApplication
  • AuditLog methods

Bugfixes

  • Errors by shards being suppressed and always being treated as being able to reconnect
    • This will now kill the application when trying to connect with invalid intents, for example
  • Enum iter not returning correct values
  • Allow include_presences to be False when GUILD_PRESENCES isn't declared for rest.request_guild_members

Packages bumped

  • multidict (4.7.6 -> 5.0.0)
  • aiohttp (3.6.2 -> 3.7.2)
  • cchardet (2.1.6 -> 2.1.7) [speedups]

Misc

  • Lots of new test
  • Removed some unreachable code

Python 3.10 support and bug fixes

13 Oct 16:28
c8d88c8
Compare
Choose a tag to compare
Pre-release

Features

  • Python 3.10 support
  • hikari.errors.RateLimitTooLongError error message improved

Bug fixes

  • Creating a guild channel and specifying a category wouldn't create the channel under that category
  • hikari.errors.RateLimitTooLongError getting raised when it shouldn't
  • max_rate_limit default increased to 5 minutes

Documentation fixes

  • hikari.undefined.UNDEFINED not being documented properly
  • Updated links to point to new website
  • index.html content appearing in search results

Pickle fixes

09 Oct 10:05
52b7345
Compare
Choose a tag to compare
Pickle fixes Pre-release
Pre-release

This will enable undefined values to be pickled correctly, as this was in a request to be fixed.

Breaking changes

  • You will no longer be able to call hikari.undefined.UndefinedType() to get a reference to hikari.undefined.UNDEFINED, you should instead access the constant value directly.

Improved handling of rate limits.

08 Oct 21:51
ef72110
Compare
Choose a tag to compare
Pre-release

No new functionality or breaking changes.


Fixes

Rate limits are now limited to sleeping for 60 seconds by default. If you are rate limited for any longer than this, you get a RateLimitTooLong error instead.

This was implemented in response to Discord actively giving "retry-after: 2 days" in rate limit headers, which previously would have made the caller wait 48 hours to perform an API call when creating roles in bulk.

Completed replacement of Python's enum internals.

04 Oct 13:49
06908ba
Compare
Choose a tag to compare

This release completes the reimplementation of Python's Enum and IntFlag types to make them much faster.

General rough benchmarks I got from my PC with general test data were as follows. You can view the full benchmark script by checking scripts/*_benchmark.py in this repository.

Operation Pure Python Hikari Implementation Performance Gain
Profiling SomeEnum(x) 1 million times 2,000,003 function calls in 0.716s 1,000,003 function calls in 0.263s +50% // +63%
--- --- --- ---
SomeEnum(x) 0.445µs 0.143µs +68%
SomeEnum._value2member_map_[x]* 0.107µs 0.046µs +57%
SomeEnum[x] 0.172µs 0.103µs +40%
--- --- --- ---
SomeFlag(x) where x is a power of 2 named member 4.061µs 1.209µs +70%
SomeFlag(x) where x is a non-power of 2 value that has never been declared before** 18.283µs 1.179µs +94%
SomeFlag(x) where x is a non-power of 2 value that has been declared before 0.418µs 0.295µs +29%

* the Hikari implementation is named _value_to_member_map_ instead of _value2member_map_.
** both Python's IntFlag and Hikari's Flag cache combinations of flags that are created, this significantly decreases the time needed to transform, construct, and validate a composite flag value later on.

Measured with following settings:

Making highest priority, os.SCHED_RR
sys.getswitchinterval 0.5
sched_getscheduler 2
sched_getparam posix.sched_param(sched_priority=1)
sched_getaffinity {7}
sched_getprioritymax 0
sched_getprioritymin 0
sched_rr_getinterval 0.09999999000000001

- CPython 3.8.5 x86_64 in non-optimised mode.
- Linux pc 5.8.11-1-MANJARO #1 SMP PREEMPT Wed Sep 23 14:35:40 UTC 2020 x86_64 GNU/Linux
- CPU
    - model name	: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
    - microcode: 0xd6
    - 6802.13 bogomips
    - hyper-threaded: 4 physical cores, 8 logical cores.
    - cache_alignment: 64
- No swap

Unlike Python's IntFlag, Hikari now limits the cache size for each enum to a maximum of 2^10 combinations. This means that for a long running bot that received a hypothetically large range of possibilities for permissions on a role via events, you would only ever see the cache grow to 8192 bytes in size (8 KiB), rather than the unbound value that Python allows which would currently be larger than
34,359,738,368 bytes (32 GiB). This means you get a potentially MASSIVE decrease in the memory footprint for your application over time, as values are no longer "leaked" in such a potentially devastating way.

In addition, these changes make a large difference to how long your application will block for when parsing medium-to-large sized guilds on start up during the Guild Create events. Enum parsing was identified as one of the biggest bottlenecks at the time, so you should notice a performance increase there.

New features

  • Flag types have new methods! You can now use these on things like intents and permissions and guild flags.
    • difference - set difference, equiv to -
    • intersection - equiv to &
    • invert - equiv to ~
    • is_disjoint
    • is_subset - equiv to in
    • is_superset - equiv to reversed in
    • symmetric_difference - equiv to ^
    • union - equiv to |
    • __len__ and __bool__ and __iter__, which now makes this conform to an AbstractSet structural supertype!
    • Operators now guaranteed to work in reverse and with raw integers.

Breaking changes

  • Flag methods renamed
    • has_all -> all
    • has_any -> any
    • has_none -> none
  • + operator for flags has been removed, and will default to the int implementation.
  • You should now compare flag members by the == operator, rather than the is operator due to internal optimisations.

Other changes

  • Documentation is less bad now, as methods on enums and flags should be documented correctly.
  • Anchors now work correctly on functions and methods.