Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does python determine whether a string is hosted or not

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "python how to judge whether the string is resident", the content of the explanation is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "python how to determine whether the string is resident" bar!

1. The declaration is defined in unicodeobject.h.

2. To check whether the string stays or not, CPython implements the PyUnicode_CHECK_INTERNED macro, which is also defined as unicodeobject.h.

PyAPI_FUNC (void) PyUnicode_InternInPlace (PyObject *)

This macro indicates that Python maintains a member variable named interned in the PyASCIObject structure, whose value indicates whether the corresponding string is retained.

# define PyUnicode_CHECK_INTERNED (op)\ (PyASCIIObject *) (op))-> state.interned)

Development

If two string objects refer to the same memory object, the is operator will get True, otherwise it will be False.

> Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report