我搜索了一段时间,发现了一些合理的说法,即 CPython 的编译允许更快地执行 Python 代码。不过,我想知道是否有人知道任何可以证明加速程度的基准测试。
或者,也许有一种简单的方法可以让我对其进行基准测试。是否有一个可以在运行时给出的Python标志来关闭编译?
当从 Google Guava 重新构建该类时com.google.common.collect.ImmutableMultimap$Values,我从 ByteBuddy 收到 IllegalArgumentException。
内部类是com.google.common.collect.ImmutableCollection其方法ImmutableList<E> createAsList()导致问题的子类。
堆栈跟踪:
Exception in thread "main" java.lang.IllegalArgumentException: Cannot attach undefined variable: V
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1896)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable$Symbolic.accept(TypeDescription.java:5551)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor.onParameterizedType(TypeDescription.java:1857)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onParameterizedType(TypeDescription.java:1896)
at net.bytebuddy.description.type.TypeDescription$Generic$OfParameterizedType.accept(TypeDescription.java:5017)
at net.bytebuddy.dynamic.Transformer$ForMethod$TransformedMethod.getReturnType(Transformer.java:377)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.asTypeToken(MethodDescription.java:685)
at net.bytebuddy.dynamic.scaffold.MethodRegistry$Default$Prepared$Entry.resolveBridgeTypes(MethodRegistry.java:916)
at net.bytebuddy.dynamic.scaffold.MethodRegistry$Default$Prepared.compile(MethodRegistry.java:778)
at net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForInlining$RedefinitionClassVisitor.visit(TypeWriter.java:3281)
at net.bytebuddy.jar.asm.ClassReader.accept(Unknown Source)
at net.bytebuddy.jar.asm.ClassReader.accept(Unknown Source)
at net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForInlining.create(TypeWriter.java:3018)
at net.bytebuddy.dynamic.scaffold.TypeWriter$Default.make(TypeWriter.java:1617)
at net.bytebuddy.dynamic.scaffold.inline.RebaseDynamicTypeBuilder.make(RebaseDynamicTypeBuilder.java:198)
at net.bytebuddy.dynamic.scaffold.inline.AbstractInliningDynamicTypeBuilder.make(AbstractInliningDynamicTypeBuilder.java:90)
at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:2566)
at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$Delegator.make(DynamicType.java:2668)
at cl.InnerClassLoader.loadClass(InnerClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at test.Stuff.<init>(Stuff.java:15)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at …Run Code Online (Sandbox Code Playgroud) 如果我反汇编我的类文件,我会得到以下形式的 LineNumberTables
LineNumberTable:
line 204: 0
line 205: 9
line 208: 57
line 209: 63
line 210: 72
line 211: 75
line 212: 78
line 213: 87
line 216: 90
line 218: 118
line 221: 126
line 222: 131
line 223: 138
line 224: 143
line 227: 150
line 230: 157
line 231: 160
line 232: 170
line 235: 194
line 237: 228
line 240: 249
line 241: 259
line 243: 266
line 245: 269
line 246: 292
line 248: …Run Code Online (Sandbox Code Playgroud) 我正在浏览 scaladocs 并遇到了AbstractSeqclass。他们将其描述为
Explicit instantiation of the Seq trait to reduce class file size in subclasses.
这如何减少子类的文件大小?子类无论如何都会获得所有方法,对吗?有人可以解释这是如何工作的吗
我正在使用 ASM 生成一些字节码并动态执行它。但在某些情况下,我需要调用私有构造函数,但我不知道如何调用。我知道可以通过反射(setAccessible)调用私有构造函数,但是我如何直接在字节码/jvm中执行此操作?
mv.visitMethodInsn(
INVOKESPECIAL, target.byteCodeName(), "<init>", "()V", false
)
Run Code Online (Sandbox Code Playgroud)
当 JVM 执行此代码时,它会抛出 java.lang.IllegalAccessError。
我在 test.py 中编写了基本的 Python 代码
\n\nprint("Hello World")\nRun Code Online (Sandbox Code Playgroud)\n\n然后,我用这段代码进行编译并生成 .pyc 文件。我现在有.py和.pyc文件。
\n\npython -m compileall\nRun Code Online (Sandbox Code Playgroud)\n\n现在,我使用dis模块来反汇编 python 字节码,但 .pyc 文件在 .py 文件工作时不起作用。
\n\n\n\n为什么pyc字节码文件不能反汇编,而py文件在编译并生成字节码后可以反汇编(.py -->(compile) --> bytecode)?
\n\n我的.pyc文件:
\n\nB\n\nhA\xc4\xb1] \xc3\xa3 @ s e d \xc6\x92 dS )zHello WorldN)\xc3\x9aprint\xc2\xa9 r r \xc3\xba"C:\\Users\\ismet\\Desktop\\deneme\\a.py\xc3\x9a<module> s \nRun Code Online (Sandbox Code Playgroud)\n\n\n\n现在谢谢了。
\n该
plotly.io.to_image函数用于以字节对象 ( Doc ) 的形式返回图像。
我想将表示 PNG 图像的字节对象转换为 numpy 数组,以便它可以在 Folium 中用作图像叠加层。
这是一个例子:
import plotly.graph_objects as go
# Create plot
fig = go.Figure(data =
go.Contour(
z=[[10, 10.625, 12.5, 15.625, 20],
[5.625, 6.25, 8.125, 11.25, 15.625],
[2.5, 3.125, 5., 8.125, 12.5],
[0.625, 1.25, 3.125, 6.25, 10.625],
[0, 0.625, 2.5, 5.625, 10]]
))
# Export byte object
img_bytes = fig.to_image(format="png",width=600, height=350)
Run Code Online (Sandbox Code Playgroud)
我尝试过使用 PIL:
from PIL import Image
img = Image.frombytes("RGB", (350,600), img_bytes)
Run Code Online (Sandbox Code Playgroud)
得到ValueError: not enough image data。
在让这个过程让我感到非常困惑之前,我从未使用过字节对象。 …
我一直在尝试理解java中嵌套类的机制。
考虑以下代码:
public class OuterClass {
private String privateOuterField = "Private Outer Field";
public static String publicStaticOuterField = "Public static outer field";
private static String privateStaticOuterField = "private static outer field";
class InnerClass{
private String privateInnerField = "Private Inner Field";
//non-final static data members not allowed in java 1.8 but allowed in java 17.0
//private static String innerClassStaticField = "Private Inner Class Static Field";
public void accessMembers() {
System.out.println(privateOuterField);
System.out.println(publicStaticOuterField);
}
}
static class StaticInnerClass{
private String privateStaticInnerField = "Private …Run Code Online (Sandbox Code Playgroud) 如何检索字节码并进行哈希以查看是否有人在内存中或文件中操作了我的字节码?
编辑: 签署二进制文件是否保护代码不被修改和执行?我想保护我的用户不要确保他们正在运行我的软件.我还想保护程序(服务器)不被黑客客户端使用.
如何从服务器端检测是否有人篡改了我的客户端?
字节代码是汇编代码和机器代码之间的代码的中间形式吗?字节码和目标代码一样吗?
这就是我的想法 - 高级语言 - >汇编语言 - >机器代码/目标代码(0s和1s.不同的CPU不同)
是这样的吗?高级语言 - >汇编语言 - >字节代码(将由虚拟机处理,将其转换为机器代码) - >机器代码
我已经读过这个 - 字节码与汇编语言代码,但需要更好地理解它
bytecode ×10
java ×6
python ×3
jvm ×2
jvm-bytecode ×2
.class-file ×1
assembly ×1
byte-buddy ×1
class ×1
cpython ×1
folium ×1
javac ×1
performance ×1
plotly ×1
python-3.x ×1
scala ×1
security ×1